repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
etcher-be/elib_miz | elib_miz/mission.py | Coalition.get_country_by_id | def get_country_by_id(self, country_id) -> 'Country':
"""
Gets a country in this coalition by its ID
Args:
country_id: country Id
Returns: Country
"""
VALID_POSITIVE_INT.validate(country_id, 'get_country_by_id', exc=ValueError)
if country_id not in s... | python | def get_country_by_id(self, country_id) -> 'Country':
"""
Gets a country in this coalition by its ID
Args:
country_id: country Id
Returns: Country
"""
VALID_POSITIVE_INT.validate(country_id, 'get_country_by_id', exc=ValueError)
if country_id not in s... | [
"def",
"get_country_by_id",
"(",
"self",
",",
"country_id",
")",
"->",
"'Country'",
":",
"VALID_POSITIVE_INT",
".",
"validate",
"(",
"country_id",
",",
"'get_country_by_id'",
",",
"exc",
"=",
"ValueError",
")",
"if",
"country_id",
"not",
"in",
"self",
".",
"_c... | Gets a country in this coalition by its ID
Args:
country_id: country Id
Returns: Country | [
"Gets",
"a",
"country",
"in",
"this",
"coalition",
"by",
"its",
"ID"
] | train | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L597-L614 |
etcher-be/elib_miz | elib_miz/mission.py | Coalition.statics | def statics(self) -> typing.Iterator['Static']:
"""
Returns: generator over all statics in this coalition
"""
for country in self.countries:
for static in country.statics:
yield static | python | def statics(self) -> typing.Iterator['Static']:
"""
Returns: generator over all statics in this coalition
"""
for country in self.countries:
for static in country.statics:
yield static | [
"def",
"statics",
"(",
"self",
")",
"->",
"typing",
".",
"Iterator",
"[",
"'Static'",
"]",
":",
"for",
"country",
"in",
"self",
".",
"countries",
":",
"for",
"static",
"in",
"country",
".",
"statics",
":",
"yield",
"static"
] | Returns: generator over all statics in this coalition | [
"Returns",
":",
"generator",
"over",
"all",
"statics",
"in",
"this",
"coalition"
] | train | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L628-L636 |
etcher-be/elib_miz | elib_miz/mission.py | Coalition.farps | def farps(self) -> typing.Iterator['Static']:
"""
Returns: generator over all FARPs in this coalition
"""
for static in self.statics:
if static.static_is_farp:
yield static | python | def farps(self) -> typing.Iterator['Static']:
"""
Returns: generator over all FARPs in this coalition
"""
for static in self.statics:
if static.static_is_farp:
yield static | [
"def",
"farps",
"(",
"self",
")",
"->",
"typing",
".",
"Iterator",
"[",
"'Static'",
"]",
":",
"for",
"static",
"in",
"self",
".",
"statics",
":",
"if",
"static",
".",
"static_is_farp",
":",
"yield",
"static"
] | Returns: generator over all FARPs in this coalition | [
"Returns",
":",
"generator",
"over",
"all",
"FARPs",
"in",
"this",
"coalition"
] | train | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L639-L646 |
etcher-be/elib_miz | elib_miz/mission.py | Coalition.get_groups_from_category | def get_groups_from_category(self, category) -> typing.Iterator['Group']:
"""
Args:
category: group category
Returns: generator over all groups from a specific category in this coalition
"""
Mission.validator_group_category.validate(category, 'get_groups_from_categor... | python | def get_groups_from_category(self, category) -> typing.Iterator['Group']:
"""
Args:
category: group category
Returns: generator over all groups from a specific category in this coalition
"""
Mission.validator_group_category.validate(category, 'get_groups_from_categor... | [
"def",
"get_groups_from_category",
"(",
"self",
",",
"category",
")",
"->",
"typing",
".",
"Iterator",
"[",
"'Group'",
"]",
":",
"Mission",
".",
"validator_group_category",
".",
"validate",
"(",
"category",
",",
"'get_groups_from_category'",
")",
"for",
"group",
... | Args:
category: group category
Returns: generator over all groups from a specific category in this coalition | [
"Args",
":",
"category",
":",
"group",
"category"
] | train | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L648-L659 |
etcher-be/elib_miz | elib_miz/mission.py | Coalition.get_units_from_category | def get_units_from_category(self, category) -> typing.Iterator['BaseUnit']:
"""
Args:
category: unit category
Returns: generator over all units of a specific category in this coalition
"""
Mission.validator_group_category.validate(category, 'group category')
... | python | def get_units_from_category(self, category) -> typing.Iterator['BaseUnit']:
"""
Args:
category: unit category
Returns: generator over all units of a specific category in this coalition
"""
Mission.validator_group_category.validate(category, 'group category')
... | [
"def",
"get_units_from_category",
"(",
"self",
",",
"category",
")",
"->",
"typing",
".",
"Iterator",
"[",
"'BaseUnit'",
"]",
":",
"Mission",
".",
"validator_group_category",
".",
"validate",
"(",
"category",
",",
"'group category'",
")",
"for",
"unit",
"in",
... | Args:
category: unit category
Returns: generator over all units of a specific category in this coalition | [
"Args",
":",
"category",
":",
"unit",
"category"
] | train | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L661-L672 |
etcher-be/elib_miz | elib_miz/mission.py | Coalition.get_group_by_id | def get_group_by_id(self, group_id) -> typing.Optional['Group']:
"""
Args:
group_id: group ID
Returns: Group
"""
VALID_POSITIVE_INT.validate(group_id, 'get_group_by_id')
for group in self.groups:
if group.group_id == group_id:
ret... | python | def get_group_by_id(self, group_id) -> typing.Optional['Group']:
"""
Args:
group_id: group ID
Returns: Group
"""
VALID_POSITIVE_INT.validate(group_id, 'get_group_by_id')
for group in self.groups:
if group.group_id == group_id:
ret... | [
"def",
"get_group_by_id",
"(",
"self",
",",
"group_id",
")",
"->",
"typing",
".",
"Optional",
"[",
"'Group'",
"]",
":",
"VALID_POSITIVE_INT",
".",
"validate",
"(",
"group_id",
",",
"'get_group_by_id'",
")",
"for",
"group",
"in",
"self",
".",
"groups",
":",
... | Args:
group_id: group ID
Returns: Group | [
"Args",
":",
"group_id",
":",
"group",
"ID"
] | train | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L674-L687 |
etcher-be/elib_miz | elib_miz/mission.py | Weather.get_season_code_from_name | def get_season_code_from_name(self, season_name) -> int:
"""
Args:
season_name: season name
Returns: season code
"""
self.validator_season_name.validate(season_name, 'get_season_code_from_name')
return self.seasons_enum[season_name] | python | def get_season_code_from_name(self, season_name) -> int:
"""
Args:
season_name: season name
Returns: season code
"""
self.validator_season_name.validate(season_name, 'get_season_code_from_name')
return self.seasons_enum[season_name] | [
"def",
"get_season_code_from_name",
"(",
"self",
",",
"season_name",
")",
"->",
"int",
":",
"self",
".",
"validator_season_name",
".",
"validate",
"(",
"season_name",
",",
"'get_season_code_from_name'",
")",
"return",
"self",
".",
"seasons_enum",
"[",
"season_name",... | Args:
season_name: season name
Returns: season code | [
"Args",
":",
"season_name",
":",
"season",
"name"
] | train | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L925-L933 |
etcher-be/elib_miz | elib_miz/mission.py | Country.groups | def groups(self) -> typing.Iterator['Group']:
"""
Returns: generator of all groups in this country
"""
for group_category in Mission.valid_group_categories:
if group_category in self._section_this_country.keys():
for group_index in self._section_this_country[g... | python | def groups(self) -> typing.Iterator['Group']:
"""
Returns: generator of all groups in this country
"""
for group_category in Mission.valid_group_categories:
if group_category in self._section_this_country.keys():
for group_index in self._section_this_country[g... | [
"def",
"groups",
"(",
"self",
")",
"->",
"typing",
".",
"Iterator",
"[",
"'Group'",
"]",
":",
"for",
"group_category",
"in",
"Mission",
".",
"valid_group_categories",
":",
"if",
"group_category",
"in",
"self",
".",
"_section_this_country",
".",
"keys",
"(",
... | Returns: generator of all groups in this country | [
"Returns",
":",
"generator",
"of",
"all",
"groups",
"in",
"this",
"country"
] | train | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L1298-L1309 |
etcher-be/elib_miz | elib_miz/mission.py | Country.statics | def statics(self) -> typing.Iterator['Static']:
"""
Returns: generator of all statics in this country
"""
if 'static' in self._section_this_country.keys():
for static_index in self._section_this_country['static']['group']:
if static_index not in self.__static:... | python | def statics(self) -> typing.Iterator['Static']:
"""
Returns: generator of all statics in this country
"""
if 'static' in self._section_this_country.keys():
for static_index in self._section_this_country['static']['group']:
if static_index not in self.__static:... | [
"def",
"statics",
"(",
"self",
")",
"->",
"typing",
".",
"Iterator",
"[",
"'Static'",
"]",
":",
"if",
"'static'",
"in",
"self",
".",
"_section_this_country",
".",
"keys",
"(",
")",
":",
"for",
"static_index",
"in",
"self",
".",
"_section_this_country",
"["... | Returns: generator of all statics in this country | [
"Returns",
":",
"generator",
"of",
"all",
"statics",
"in",
"this",
"country"
] | train | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L1312-L1321 |
etcher-be/elib_miz | elib_miz/mission.py | Country.get_group_by_id | def get_group_by_id(self, group_id) -> typing.Optional['Group']:
"""
Args:
group_id: group id
Returns: Group
"""
for group in self.groups:
if group.group_id == group_id:
return group
return None | python | def get_group_by_id(self, group_id) -> typing.Optional['Group']:
"""
Args:
group_id: group id
Returns: Group
"""
for group in self.groups:
if group.group_id == group_id:
return group
return None | [
"def",
"get_group_by_id",
"(",
"self",
",",
"group_id",
")",
"->",
"typing",
".",
"Optional",
"[",
"'Group'",
"]",
":",
"for",
"group",
"in",
"self",
".",
"groups",
":",
"if",
"group",
".",
"group_id",
"==",
"group_id",
":",
"return",
"group",
"return",
... | Args:
group_id: group id
Returns: Group | [
"Args",
":",
"group_id",
":",
"group",
"id"
] | train | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L1336-L1348 |
etcher-be/elib_miz | elib_miz/mission.py | Static.static_position | def static_position(self) -> typing.Tuple[float, float]:
"""
Returns: position of this static
"""
unit = self._section_static['units'][1]
return unit['x'], unit['y'] | python | def static_position(self) -> typing.Tuple[float, float]:
"""
Returns: position of this static
"""
unit = self._section_static['units'][1]
return unit['x'], unit['y'] | [
"def",
"static_position",
"(",
"self",
")",
"->",
"typing",
".",
"Tuple",
"[",
"float",
",",
"float",
"]",
":",
"unit",
"=",
"self",
".",
"_section_static",
"[",
"'units'",
"]",
"[",
"1",
"]",
"return",
"unit",
"[",
"'x'",
"]",
",",
"unit",
"[",
"'... | Returns: position of this static | [
"Returns",
":",
"position",
"of",
"this",
"static"
] | train | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L1407-L1412 |
etcher-be/elib_miz | elib_miz/mission.py | Group.group_route | def group_route(self) -> 'Group.Route':
"""
Returns: route of this group
"""
# TODO
if self.__group_route is None:
self.__group_route = Group.Route(self)
return self.__group_route | python | def group_route(self) -> 'Group.Route':
"""
Returns: route of this group
"""
# TODO
if self.__group_route is None:
self.__group_route = Group.Route(self)
return self.__group_route | [
"def",
"group_route",
"(",
"self",
")",
"->",
"'Group.Route'",
":",
"# TODO",
"if",
"self",
".",
"__group_route",
"is",
"None",
":",
"self",
".",
"__group_route",
"=",
"Group",
".",
"Route",
"(",
"self",
")",
"return",
"self",
".",
"__group_route"
] | Returns: route of this group | [
"Returns",
":",
"route",
"of",
"this",
"group"
] | train | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L1483-L1490 |
etcher-be/elib_miz | elib_miz/mission.py | Group.units | def units(self) -> typing.Iterator['BaseUnit']:
"""
Returns: generator over all units of this group
"""
for unit_index in self._section_group['units']:
if unit_index not in self.__units.keys():
_category = self.units_class_enum[self.group_category] # type: ig... | python | def units(self) -> typing.Iterator['BaseUnit']:
"""
Returns: generator over all units of this group
"""
for unit_index in self._section_group['units']:
if unit_index not in self.__units.keys():
_category = self.units_class_enum[self.group_category] # type: ig... | [
"def",
"units",
"(",
"self",
")",
"->",
"typing",
".",
"Iterator",
"[",
"'BaseUnit'",
"]",
":",
"for",
"unit_index",
"in",
"self",
".",
"_section_group",
"[",
"'units'",
"]",
":",
"if",
"unit_index",
"not",
"in",
"self",
".",
"__units",
".",
"keys",
"(... | Returns: generator over all units of this group | [
"Returns",
":",
"generator",
"over",
"all",
"units",
"of",
"this",
"group"
] | train | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L1575-L1586 |
etcher-be/elib_miz | elib_miz/mission.py | Group.get_unit_by_index | def get_unit_by_index(self, unit_index) -> typing.Optional['BaseUnit']:
"""
Args:
unit_index: index of unit
Returns: a unit of this group
"""
if unit_index in self._section_group['units'].keys():
if unit_index not in self.__units.keys():
_... | python | def get_unit_by_index(self, unit_index) -> typing.Optional['BaseUnit']:
"""
Args:
unit_index: index of unit
Returns: a unit of this group
"""
if unit_index in self._section_group['units'].keys():
if unit_index not in self.__units.keys():
_... | [
"def",
"get_unit_by_index",
"(",
"self",
",",
"unit_index",
")",
"->",
"typing",
".",
"Optional",
"[",
"'BaseUnit'",
"]",
":",
"if",
"unit_index",
"in",
"self",
".",
"_section_group",
"[",
"'units'",
"]",
".",
"keys",
"(",
")",
":",
"if",
"unit_index",
"... | Args:
unit_index: index of unit
Returns: a unit of this group | [
"Args",
":",
"unit_index",
":",
"index",
"of",
"unit"
] | train | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L1601-L1616 |
etcher-be/elib_miz | elib_miz/mission.py | Group.group_is_client_group | def group_is_client_group(self) -> bool:
"""
Returns: True if this group is a client group
"""
# TODO create test
first_unit = self.get_unit_by_index(1)
if first_unit:
return first_unit.skill == 'Client'
return False | python | def group_is_client_group(self) -> bool:
"""
Returns: True if this group is a client group
"""
# TODO create test
first_unit = self.get_unit_by_index(1)
if first_unit:
return first_unit.skill == 'Client'
return False | [
"def",
"group_is_client_group",
"(",
"self",
")",
"->",
"bool",
":",
"# TODO create test",
"first_unit",
"=",
"self",
".",
"get_unit_by_index",
"(",
"1",
")",
"if",
"first_unit",
":",
"return",
"first_unit",
".",
"skill",
"==",
"'Client'",
"return",
"False"
] | Returns: True if this group is a client group | [
"Returns",
":",
"True",
"if",
"this",
"group",
"is",
"a",
"client",
"group"
] | train | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L1619-L1628 |
etcher-be/elib_miz | elib_miz/mission.py | BaseUnit.unit_position | def unit_position(self) -> typing.Tuple[float, float]:
"""
Returns: unit position
"""
return self.unit_pos_x, self.unit_pos_y | python | def unit_position(self) -> typing.Tuple[float, float]:
"""
Returns: unit position
"""
return self.unit_pos_x, self.unit_pos_y | [
"def",
"unit_position",
"(",
"self",
")",
"->",
"typing",
".",
"Tuple",
"[",
"float",
",",
"float",
"]",
":",
"return",
"self",
".",
"unit_pos_x",
",",
"self",
".",
"unit_pos_y"
] | Returns: unit position | [
"Returns",
":",
"unit",
"position"
] | train | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L1750-L1754 |
etcher-be/elib_miz | elib_miz/mission.py | BaseUnit.radio_presets | def radio_presets(self) -> typing.Iterator['FlyingUnit.RadioPresets']:
"""
Returns: generator over unit radio presets
"""
raise TypeError('unit #{}: {}'.format(self.unit_id, self.unit_name)) | python | def radio_presets(self) -> typing.Iterator['FlyingUnit.RadioPresets']:
"""
Returns: generator over unit radio presets
"""
raise TypeError('unit #{}: {}'.format(self.unit_id, self.unit_name)) | [
"def",
"radio_presets",
"(",
"self",
")",
"->",
"typing",
".",
"Iterator",
"[",
"'FlyingUnit.RadioPresets'",
"]",
":",
"raise",
"TypeError",
"(",
"'unit #{}: {}'",
".",
"format",
"(",
"self",
".",
"unit_id",
",",
"self",
".",
"unit_name",
")",
")"
] | Returns: generator over unit radio presets | [
"Returns",
":",
"generator",
"over",
"unit",
"radio",
"presets"
] | train | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L1773-L1777 |
etcher-be/elib_miz | elib_miz/mission.py | BaseUnit.has_radio_presets | def has_radio_presets(self) -> bool:
"""
Returns: true if unit has radio presets
"""
return all([self.skill == 'Client', self.unit_type in FlyingUnit.RadioPresets.radio_enum.keys()]) | python | def has_radio_presets(self) -> bool:
"""
Returns: true if unit has radio presets
"""
return all([self.skill == 'Client', self.unit_type in FlyingUnit.RadioPresets.radio_enum.keys()]) | [
"def",
"has_radio_presets",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"all",
"(",
"[",
"self",
".",
"skill",
"==",
"'Client'",
",",
"self",
".",
"unit_type",
"in",
"FlyingUnit",
".",
"RadioPresets",
".",
"radio_enum",
".",
"keys",
"(",
")",
"]",
"... | Returns: true if unit has radio presets | [
"Returns",
":",
"true",
"if",
"unit",
"has",
"radio",
"presets"
] | train | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L1780-L1784 |
etcher-be/elib_miz | elib_miz/mission.py | FlyingUnit.radio_presets | def radio_presets(self) -> typing.Iterator['FlyingUnit.RadioPresets']:
"""
Returns: radio presets for this unit
"""
if self.skill == 'Client' and self.unit_type in FlyingUnit.RadioPresets.radio_enum.keys():
for k in self._section_unit['Radio']:
yield FlyingUni... | python | def radio_presets(self) -> typing.Iterator['FlyingUnit.RadioPresets']:
"""
Returns: radio presets for this unit
"""
if self.skill == 'Client' and self.unit_type in FlyingUnit.RadioPresets.radio_enum.keys():
for k in self._section_unit['Radio']:
yield FlyingUni... | [
"def",
"radio_presets",
"(",
"self",
")",
"->",
"typing",
".",
"Iterator",
"[",
"'FlyingUnit.RadioPresets'",
"]",
":",
"if",
"self",
".",
"skill",
"==",
"'Client'",
"and",
"self",
".",
"unit_type",
"in",
"FlyingUnit",
".",
"RadioPresets",
".",
"radio_enum",
... | Returns: radio presets for this unit | [
"Returns",
":",
"radio",
"presets",
"for",
"this",
"unit"
] | train | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L2038-L2046 |
etcher-be/elib_miz | elib_miz/mission.py | FlyingUnit.get_radio_by_name | def get_radio_by_name(self, radio_name: str) -> 'RadioPresets':
"""
Args:
radio_name: radio name
Returns: radio presets for this radio
"""
if self.has_radio_presets:
for k in FlyingUnit.RadioPresets.radio_enum[self.unit_type].keys():
if ra... | python | def get_radio_by_name(self, radio_name: str) -> 'RadioPresets':
"""
Args:
radio_name: radio name
Returns: radio presets for this radio
"""
if self.has_radio_presets:
for k in FlyingUnit.RadioPresets.radio_enum[self.unit_type].keys():
if ra... | [
"def",
"get_radio_by_name",
"(",
"self",
",",
"radio_name",
":",
"str",
")",
"->",
"'RadioPresets'",
":",
"if",
"self",
".",
"has_radio_presets",
":",
"for",
"k",
"in",
"FlyingUnit",
".",
"RadioPresets",
".",
"radio_enum",
"[",
"self",
".",
"unit_type",
"]",... | Args:
radio_name: radio name
Returns: radio presets for this radio | [
"Args",
":",
"radio_name",
":",
"radio",
"name"
] | train | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L2058-L2071 |
etcher-be/elib_miz | elib_miz/mission.py | FlyingUnit.get_radio_by_number | def get_radio_by_number(self, radio_number) -> 'RadioPresets':
"""
Args:
radio_number: radio number
Returns: presets for this radio
"""
if self.has_radio_presets:
if radio_number in FlyingUnit.RadioPresets.radio_enum[self.unit_type].keys():
... | python | def get_radio_by_number(self, radio_number) -> 'RadioPresets':
"""
Args:
radio_number: radio number
Returns: presets for this radio
"""
if self.has_radio_presets:
if radio_number in FlyingUnit.RadioPresets.radio_enum[self.unit_type].keys():
... | [
"def",
"get_radio_by_number",
"(",
"self",
",",
"radio_number",
")",
"->",
"'RadioPresets'",
":",
"if",
"self",
".",
"has_radio_presets",
":",
"if",
"radio_number",
"in",
"FlyingUnit",
".",
"RadioPresets",
".",
"radio_enum",
"[",
"self",
".",
"unit_type",
"]",
... | Args:
radio_number: radio number
Returns: presets for this radio | [
"Args",
":",
"radio_number",
":",
"radio",
"number"
] | train | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/mission.py#L2073-L2087 |
guidj/jsonuri-py | jsonuri/io.py | compress | def compress(data):
"""
Compresses a string (or bytes) using Gzip and returns its Base64 representation
:param data: string or bytes
:return: Base64 (bytes) representation of compressed data
"""
if isinstance(data, bytes):
source = data
elif isinstance(data, str):
source = ... | python | def compress(data):
"""
Compresses a string (or bytes) using Gzip and returns its Base64 representation
:param data: string or bytes
:return: Base64 (bytes) representation of compressed data
"""
if isinstance(data, bytes):
source = data
elif isinstance(data, str):
source = ... | [
"def",
"compress",
"(",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"bytes",
")",
":",
"source",
"=",
"data",
"elif",
"isinstance",
"(",
"data",
",",
"str",
")",
":",
"source",
"=",
"bytes",
"(",
"data",
",",
"encoding",
"=",
"'utf-8'",
... | Compresses a string (or bytes) using Gzip and returns its Base64 representation
:param data: string or bytes
:return: Base64 (bytes) representation of compressed data | [
"Compresses",
"a",
"string",
"(",
"or",
"bytes",
")",
"using",
"Gzip",
"and",
"returns",
"its",
"Base64",
"representation"
] | train | https://github.com/guidj/jsonuri-py/blob/0e266be86a52dc93d792b05e458e07f0b279e490/jsonuri/io.py#L5-L20 |
guidj/jsonuri-py | jsonuri/io.py | decompress | def decompress(data):
"""
Decodes a Base64 bytes (or string) input and decompresses it using Gzip
:param data: Base64 (bytes) data to be decoded
:return: Decompressed and decoded bytes
"""
if isinstance(data, bytes):
source = data
elif isinstance(data, str):
source = bytes(d... | python | def decompress(data):
"""
Decodes a Base64 bytes (or string) input and decompresses it using Gzip
:param data: Base64 (bytes) data to be decoded
:return: Decompressed and decoded bytes
"""
if isinstance(data, bytes):
source = data
elif isinstance(data, str):
source = bytes(d... | [
"def",
"decompress",
"(",
"data",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"bytes",
")",
":",
"source",
"=",
"data",
"elif",
"isinstance",
"(",
"data",
",",
"str",
")",
":",
"source",
"=",
"bytes",
"(",
"data",
",",
"encoding",
"=",
"'utf-8'",... | Decodes a Base64 bytes (or string) input and decompresses it using Gzip
:param data: Base64 (bytes) data to be decoded
:return: Decompressed and decoded bytes | [
"Decodes",
"a",
"Base64",
"bytes",
"(",
"or",
"string",
")",
"input",
"and",
"decompresses",
"it",
"using",
"Gzip",
":",
"param",
"data",
":",
"Base64",
"(",
"bytes",
")",
"data",
"to",
"be",
"decoded",
":",
"return",
":",
"Decompressed",
"and",
"decoded... | train | https://github.com/guidj/jsonuri-py/blob/0e266be86a52dc93d792b05e458e07f0b279e490/jsonuri/io.py#L23-L37 |
mrstephenneal/PyBundle | PyBundle/PyBundle.py | bundle_dir | def bundle_dir():
"""Handle resource management within an executable file."""
if frozen():
directory = sys._MEIPASS
else:
directory = os.path.dirname(os.path.abspath(stack()[1][1]))
if os.path.exists(directory):
return directory | python | def bundle_dir():
"""Handle resource management within an executable file."""
if frozen():
directory = sys._MEIPASS
else:
directory = os.path.dirname(os.path.abspath(stack()[1][1]))
if os.path.exists(directory):
return directory | [
"def",
"bundle_dir",
"(",
")",
":",
"if",
"frozen",
"(",
")",
":",
"directory",
"=",
"sys",
".",
"_MEIPASS",
"else",
":",
"directory",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"stack",
"(",
")",
"[",
"1... | Handle resource management within an executable file. | [
"Handle",
"resource",
"management",
"within",
"an",
"executable",
"file",
"."
] | train | https://github.com/mrstephenneal/PyBundle/blob/44f538d6d6a2acaac55b4305db9427a5d7b14164/PyBundle/PyBundle.py#L25-L32 |
mrstephenneal/PyBundle | PyBundle/PyBundle.py | resource_path | def resource_path(relative):
"""Adjust path for executable use in executable file"""
if hasattr(sys, "_MEIPASS"):
return os.path.join(sys._MEIPASS, relative)
return os.path.join(relative) | python | def resource_path(relative):
"""Adjust path for executable use in executable file"""
if hasattr(sys, "_MEIPASS"):
return os.path.join(sys._MEIPASS, relative)
return os.path.join(relative) | [
"def",
"resource_path",
"(",
"relative",
")",
":",
"if",
"hasattr",
"(",
"sys",
",",
"\"_MEIPASS\"",
")",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"sys",
".",
"_MEIPASS",
",",
"relative",
")",
"return",
"os",
".",
"path",
".",
"join",
"(",... | Adjust path for executable use in executable file | [
"Adjust",
"path",
"for",
"executable",
"use",
"in",
"executable",
"file"
] | train | https://github.com/mrstephenneal/PyBundle/blob/44f538d6d6a2acaac55b4305db9427a5d7b14164/PyBundle/PyBundle.py#L35-L39 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/refer/Descriptor.py | Descriptor.match | def match(self, descriptor):
"""
Partially matches this descriptor to another descriptor.
Fields that contain "*" or null are excluded from the match.
:param descriptor: the descriptor to match this one against.
:return: true if descriptors match and false otherwise
"""... | python | def match(self, descriptor):
"""
Partially matches this descriptor to another descriptor.
Fields that contain "*" or null are excluded from the match.
:param descriptor: the descriptor to match this one against.
:return: true if descriptors match and false otherwise
"""... | [
"def",
"match",
"(",
"self",
",",
"descriptor",
")",
":",
"return",
"self",
".",
"_match_field",
"(",
"self",
".",
"_group",
",",
"descriptor",
".",
"get_group",
"(",
")",
")",
"and",
"self",
".",
"_match_field",
"(",
"self",
".",
"_type",
",",
"descri... | Partially matches this descriptor to another descriptor.
Fields that contain "*" or null are excluded from the match.
:param descriptor: the descriptor to match this one against.
:return: true if descriptors match and false otherwise | [
"Partially",
"matches",
"this",
"descriptor",
"to",
"another",
"descriptor",
".",
"Fields",
"that",
"contain",
"*",
"or",
"null",
"are",
"excluded",
"from",
"the",
"match",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/refer/Descriptor.py#L117-L130 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/refer/Descriptor.py | Descriptor.is_complete | def is_complete(self):
"""
Checks whether all descriptor fields are set.
If descriptor has at least one "*" or null field it is considered "incomplete"
:return: true if all descriptor fields are defined and false otherwise.
"""
return self._group != None and self._type !... | python | def is_complete(self):
"""
Checks whether all descriptor fields are set.
If descriptor has at least one "*" or null field it is considered "incomplete"
:return: true if all descriptor fields are defined and false otherwise.
"""
return self._group != None and self._type !... | [
"def",
"is_complete",
"(",
"self",
")",
":",
"return",
"self",
".",
"_group",
"!=",
"None",
"and",
"self",
".",
"_type",
"!=",
"None",
"and",
"self",
".",
"_kind",
"!=",
"None",
"and",
"self",
".",
"_name",
"!=",
"None",
"and",
"self",
".",
"_version... | Checks whether all descriptor fields are set.
If descriptor has at least one "*" or null field it is considered "incomplete"
:return: true if all descriptor fields are defined and false otherwise. | [
"Checks",
"whether",
"all",
"descriptor",
"fields",
"are",
"set",
".",
"If",
"descriptor",
"has",
"at",
"least",
"one",
"*",
"or",
"null",
"field",
"it",
"is",
"considered",
"incomplete"
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/refer/Descriptor.py#L153-L161 |
pip-services3-python/pip-services3-commons-python | pip_services3_commons/refer/Descriptor.py | Descriptor.from_string | def from_string(value):
"""
Parses colon-separated list of descriptor fields and returns them as a Descriptor.
:param value: colon-separated descriptor fields to initialize Descriptor.
:return: a newly created Descriptor.
"""
if value == None or len(value) == 0:
... | python | def from_string(value):
"""
Parses colon-separated list of descriptor fields and returns them as a Descriptor.
:param value: colon-separated descriptor fields to initialize Descriptor.
:return: a newly created Descriptor.
"""
if value == None or len(value) == 0:
... | [
"def",
"from_string",
"(",
"value",
")",
":",
"if",
"value",
"==",
"None",
"or",
"len",
"(",
"value",
")",
"==",
"0",
":",
"return",
"None",
"tokens",
"=",
"value",
".",
"split",
"(",
"\":\"",
")",
"if",
"len",
"(",
"tokens",
")",
"!=",
"5",
":",... | Parses colon-separated list of descriptor fields and returns them as a Descriptor.
:param value: colon-separated descriptor fields to initialize Descriptor.
:return: a newly created Descriptor. | [
"Parses",
"colon",
"-",
"separated",
"list",
"of",
"descriptor",
"fields",
"and",
"returns",
"them",
"as",
"a",
"Descriptor",
"."
] | train | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/refer/Descriptor.py#L199-L216 |
toumorokoshi/jenks | jenks/subcommand/config.py | _parse_add_url | def _parse_add_url(url):
""" return a tuple (host, job_name) from a url """
parsed_url = urlparse(url)
job_name = None
paths = parsed_url.path.strip("/").split("/")
for i, path in enumerate(paths):
if path == "job" and len(paths) > i:
job_name = paths[i + 1]
if job_name is No... | python | def _parse_add_url(url):
""" return a tuple (host, job_name) from a url """
parsed_url = urlparse(url)
job_name = None
paths = parsed_url.path.strip("/").split("/")
for i, path in enumerate(paths):
if path == "job" and len(paths) > i:
job_name = paths[i + 1]
if job_name is No... | [
"def",
"_parse_add_url",
"(",
"url",
")",
":",
"parsed_url",
"=",
"urlparse",
"(",
"url",
")",
"job_name",
"=",
"None",
"paths",
"=",
"parsed_url",
".",
"path",
".",
"strip",
"(",
"\"/\"",
")",
".",
"split",
"(",
"\"/\"",
")",
"for",
"i",
",",
"path"... | return a tuple (host, job_name) from a url | [
"return",
"a",
"tuple",
"(",
"host",
"job_name",
")",
"from",
"a",
"url"
] | train | https://github.com/toumorokoshi/jenks/blob/d3333a7b86ba290b7185aa5b8da75e76a28124f5/jenks/subcommand/config.py#L35-L48 |
FujiMakoto/AgentML | agentml/parser/tags/random.py | Random._parse | def _parse(self):
"""
Generates a dictionary of responses from a <random> element
"""
responses = []
for child in self._element:
weight = int_attribute(child, 'weight', 1)
self._log.debug('Parsing random entry with weight {weight}: {entry}'
... | python | def _parse(self):
"""
Generates a dictionary of responses from a <random> element
"""
responses = []
for child in self._element:
weight = int_attribute(child, 'weight', 1)
self._log.debug('Parsing random entry with weight {weight}: {entry}'
... | [
"def",
"_parse",
"(",
"self",
")",
":",
"responses",
"=",
"[",
"]",
"for",
"child",
"in",
"self",
".",
"_element",
":",
"weight",
"=",
"int_attribute",
"(",
"child",
",",
"'weight'",
",",
"1",
")",
"self",
".",
"_log",
".",
"debug",
"(",
"'Parsing ra... | Generates a dictionary of responses from a <random> element | [
"Generates",
"a",
"dictionary",
"of",
"responses",
"from",
"a",
"<random",
">",
"element"
] | train | https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/parser/tags/random.py#L26-L43 |
FujiMakoto/AgentML | agentml/parser/tags/random.py | Random.value | def value(self):
"""
Fetch a random weighted choice
"""
choice = weighted_choice(self._responses)
# If the choice is a tuple, join the elements into a single mapped string
if isinstance(choice, tuple):
return ''.join(map(str, choice)).strip()
# Other... | python | def value(self):
"""
Fetch a random weighted choice
"""
choice = weighted_choice(self._responses)
# If the choice is a tuple, join the elements into a single mapped string
if isinstance(choice, tuple):
return ''.join(map(str, choice)).strip()
# Other... | [
"def",
"value",
"(",
"self",
")",
":",
"choice",
"=",
"weighted_choice",
"(",
"self",
".",
"_responses",
")",
"# If the choice is a tuple, join the elements into a single mapped string",
"if",
"isinstance",
"(",
"choice",
",",
"tuple",
")",
":",
"return",
"''",
".",... | Fetch a random weighted choice | [
"Fetch",
"a",
"random",
"weighted",
"choice"
] | train | https://github.com/FujiMakoto/AgentML/blob/c8cb64b460d876666bf29ea2c682189874c7c403/agentml/parser/tags/random.py#L45-L56 |
SeabornGames/RequestClient | example_bindings/echo.py | Echo_String.post | def post(self, message):
"""
Simply test Put a string
:param message: str of the message
:return: str of the message
"""
return self.connection.post('echo/string', data=dict(message=message)) | python | def post(self, message):
"""
Simply test Put a string
:param message: str of the message
:return: str of the message
"""
return self.connection.post('echo/string', data=dict(message=message)) | [
"def",
"post",
"(",
"self",
",",
"message",
")",
":",
"return",
"self",
".",
"connection",
".",
"post",
"(",
"'echo/string'",
",",
"data",
"=",
"dict",
"(",
"message",
"=",
"message",
")",
")"
] | Simply test Put a string
:param message: str of the message
:return: str of the message | [
"Simply",
"test",
"Put",
"a",
"string",
":",
"param",
"message",
":",
"str",
"of",
"the",
"message",
":",
"return",
":",
"str",
"of",
"the",
"message"
] | train | https://github.com/SeabornGames/RequestClient/blob/21aeb951ddfdb6ee453ad0edc896ff224e06425d/example_bindings/echo.py#L80-L86 |
SeabornGames/RequestClient | example_bindings/echo.py | Echo_String.put | def put(self, message):
"""
Simply test Put a string
:param message: str of the message
:return: str of the message
"""
return self.connection.put('echo/string', data=dict(message=message)) | python | def put(self, message):
"""
Simply test Put a string
:param message: str of the message
:return: str of the message
"""
return self.connection.put('echo/string', data=dict(message=message)) | [
"def",
"put",
"(",
"self",
",",
"message",
")",
":",
"return",
"self",
".",
"connection",
".",
"put",
"(",
"'echo/string'",
",",
"data",
"=",
"dict",
"(",
"message",
"=",
"message",
")",
")"
] | Simply test Put a string
:param message: str of the message
:return: str of the message | [
"Simply",
"test",
"Put",
"a",
"string",
":",
"param",
"message",
":",
"str",
"of",
"the",
"message",
":",
"return",
":",
"str",
"of",
"the",
"message"
] | train | https://github.com/SeabornGames/RequestClient/blob/21aeb951ddfdb6ee453ad0edc896ff224e06425d/example_bindings/echo.py#L88-L94 |
SeabornGames/RequestClient | example_bindings/echo.py | Echo_Key.post | def post(self, key='hello', value='world'):
"""
This takes two parameters a key and a value and temporarily stores them on the server
:param key: str of key to store the value under
:param value: str of the value to store
:return: Echo dict of the key value store... | python | def post(self, key='hello', value='world'):
"""
This takes two parameters a key and a value and temporarily stores them on the server
:param key: str of key to store the value under
:param value: str of the value to store
:return: Echo dict of the key value store... | [
"def",
"post",
"(",
"self",
",",
"key",
"=",
"'hello'",
",",
"value",
"=",
"'world'",
")",
":",
"return",
"self",
".",
"connection",
".",
"post",
"(",
"'echo/key'",
",",
"data",
"=",
"dict",
"(",
"key",
"=",
"key",
",",
"value",
"=",
"value",
")",
... | This takes two parameters a key and a value and temporarily stores them on the server
:param key: str of key to store the value under
:param value: str of the value to store
:return: Echo dict of the key value stored | [
"This",
"takes",
"two",
"parameters",
"a",
"key",
"and",
"a",
"value",
"and",
"temporarily",
"stores",
"them",
"on",
"the",
"server",
":",
"param",
"key",
":",
"str",
"of",
"key",
"to",
"store",
"the",
"value",
"under",
":",
"param",
"value",
":",
"str... | train | https://github.com/SeabornGames/RequestClient/blob/21aeb951ddfdb6ee453ad0edc896ff224e06425d/example_bindings/echo.py#L121-L128 |
SeabornGames/RequestClient | example_bindings/echo.py | Echo_Key.put | def put(self, key='hello', value='world'):
"""
This takes two parameters a key and a value and temporarily stores them on the server
:param key: str of key to store the value under
:param value: str of the value to store
:return: Echo dict of the key value stored... | python | def put(self, key='hello', value='world'):
"""
This takes two parameters a key and a value and temporarily stores them on the server
:param key: str of key to store the value under
:param value: str of the value to store
:return: Echo dict of the key value stored... | [
"def",
"put",
"(",
"self",
",",
"key",
"=",
"'hello'",
",",
"value",
"=",
"'world'",
")",
":",
"return",
"self",
".",
"connection",
".",
"put",
"(",
"'echo/key'",
",",
"data",
"=",
"dict",
"(",
"key",
"=",
"key",
",",
"value",
"=",
"value",
")",
... | This takes two parameters a key and a value and temporarily stores them on the server
:param key: str of key to store the value under
:param value: str of the value to store
:return: Echo dict of the key value stored | [
"This",
"takes",
"two",
"parameters",
"a",
"key",
"and",
"a",
"value",
"and",
"temporarily",
"stores",
"them",
"on",
"the",
"server",
":",
"param",
"key",
":",
"str",
"of",
"key",
"to",
"store",
"the",
"value",
"under",
":",
"param",
"value",
":",
"str... | train | https://github.com/SeabornGames/RequestClient/blob/21aeb951ddfdb6ee453ad0edc896ff224e06425d/example_bindings/echo.py#L130-L137 |
kaniblu/pydumper | dumper/__init__.py | dump | def dump(obj, name, path=None, ext="dat", overwrite=True, silent=False):
"""
Dumps the object to disk with given name and extension.
Optionally the path can be specified as well. (But nothing stops
you from adding path to the name.
"""
if path and os.path.isfile(path):
raise ValueExcepti... | python | def dump(obj, name, path=None, ext="dat", overwrite=True, silent=False):
"""
Dumps the object to disk with given name and extension.
Optionally the path can be specified as well. (But nothing stops
you from adding path to the name.
"""
if path and os.path.isfile(path):
raise ValueExcepti... | [
"def",
"dump",
"(",
"obj",
",",
"name",
",",
"path",
"=",
"None",
",",
"ext",
"=",
"\"dat\"",
",",
"overwrite",
"=",
"True",
",",
"silent",
"=",
"False",
")",
":",
"if",
"path",
"and",
"os",
".",
"path",
".",
"isfile",
"(",
"path",
")",
":",
"r... | Dumps the object to disk with given name and extension.
Optionally the path can be specified as well. (But nothing stops
you from adding path to the name. | [
"Dumps",
"the",
"object",
"to",
"disk",
"with",
"given",
"name",
"and",
"extension",
".",
"Optionally",
"the",
"path",
"can",
"be",
"specified",
"as",
"well",
".",
"(",
"But",
"nothing",
"stops",
"you",
"from",
"adding",
"path",
"to",
"the",
"name",
"."
... | train | https://github.com/kaniblu/pydumper/blob/ce61b96b09604b52d4bab667ac1862755ca21f3b/dumper/__init__.py#L14-L31 |
kaniblu/pydumper | dumper/__init__.py | load | def load(name, path=None, ext="dat", silent=False):
"""
Loads an object from file with given name and extension.
Optionally the path can be specified as well.
"""
filename = __get_filename(path, name, ext)
if not os.path.exists(filename):
if not silent:
raise ValueException(... | python | def load(name, path=None, ext="dat", silent=False):
"""
Loads an object from file with given name and extension.
Optionally the path can be specified as well.
"""
filename = __get_filename(path, name, ext)
if not os.path.exists(filename):
if not silent:
raise ValueException(... | [
"def",
"load",
"(",
"name",
",",
"path",
"=",
"None",
",",
"ext",
"=",
"\"dat\"",
",",
"silent",
"=",
"False",
")",
":",
"filename",
"=",
"__get_filename",
"(",
"path",
",",
"name",
",",
"ext",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
... | Loads an object from file with given name and extension.
Optionally the path can be specified as well. | [
"Loads",
"an",
"object",
"from",
"file",
"with",
"given",
"name",
"and",
"extension",
".",
"Optionally",
"the",
"path",
"can",
"be",
"specified",
"as",
"well",
"."
] | train | https://github.com/kaniblu/pydumper/blob/ce61b96b09604b52d4bab667ac1862755ca21f3b/dumper/__init__.py#L33-L46 |
bufferapp/pipub | pipub/cli.py | standard_input | def standard_input():
"""Generator that yields lines from standard input."""
with click.get_text_stream("stdin") as stdin:
while stdin.readable():
line = stdin.readline()
if line:
yield line.strip().encode("utf-8") | python | def standard_input():
"""Generator that yields lines from standard input."""
with click.get_text_stream("stdin") as stdin:
while stdin.readable():
line = stdin.readline()
if line:
yield line.strip().encode("utf-8") | [
"def",
"standard_input",
"(",
")",
":",
"with",
"click",
".",
"get_text_stream",
"(",
"\"stdin\"",
")",
"as",
"stdin",
":",
"while",
"stdin",
".",
"readable",
"(",
")",
":",
"line",
"=",
"stdin",
".",
"readline",
"(",
")",
"if",
"line",
":",
"yield",
... | Generator that yields lines from standard input. | [
"Generator",
"that",
"yields",
"lines",
"from",
"standard",
"input",
"."
] | train | https://github.com/bufferapp/pipub/blob/1270b2cc3b72ddbe57874757dcf5537d3d36e189/pipub/cli.py#L6-L12 |
rtluckie/seria | seria/cli.py | cli | def cli(out_fmt, input, output):
"""Converts text."""
_input = StringIO()
for l in input:
try:
_input.write(str(l))
except TypeError:
_input.write(bytes(l, 'utf-8'))
_input = seria.load(_input)
_out = (_input.dump(out_fmt))
output.write(_out) | python | def cli(out_fmt, input, output):
"""Converts text."""
_input = StringIO()
for l in input:
try:
_input.write(str(l))
except TypeError:
_input.write(bytes(l, 'utf-8'))
_input = seria.load(_input)
_out = (_input.dump(out_fmt))
output.write(_out) | [
"def",
"cli",
"(",
"out_fmt",
",",
"input",
",",
"output",
")",
":",
"_input",
"=",
"StringIO",
"(",
")",
"for",
"l",
"in",
"input",
":",
"try",
":",
"_input",
".",
"write",
"(",
"str",
"(",
"l",
")",
")",
"except",
"TypeError",
":",
"_input",
".... | Converts text. | [
"Converts",
"text",
"."
] | train | https://github.com/rtluckie/seria/blob/8ae4f71237e69085d8f974a024720f45b34ab963/seria/cli.py#L23-L33 |
jespino/anillo | anillo/utils/multipart.py | copy_file | def copy_file(stream, target, maxread=-1, buffer_size=2*16):
''' Read from :stream and write to :target until :maxread or EOF. '''
size, read = 0, stream.read
while 1:
to_read = buffer_size if maxread < 0 else min(buffer_size, maxread-size)
part = read(to_read)
if not part:
... | python | def copy_file(stream, target, maxread=-1, buffer_size=2*16):
''' Read from :stream and write to :target until :maxread or EOF. '''
size, read = 0, stream.read
while 1:
to_read = buffer_size if maxread < 0 else min(buffer_size, maxread-size)
part = read(to_read)
if not part:
... | [
"def",
"copy_file",
"(",
"stream",
",",
"target",
",",
"maxread",
"=",
"-",
"1",
",",
"buffer_size",
"=",
"2",
"*",
"16",
")",
":",
"size",
",",
"read",
"=",
"0",
",",
"stream",
".",
"read",
"while",
"1",
":",
"to_read",
"=",
"buffer_size",
"if",
... | Read from :stream and write to :target until :maxread or EOF. | [
"Read",
"from",
":",
"stream",
"and",
"write",
"to",
":",
"target",
"until",
":",
"maxread",
"or",
"EOF",
"."
] | train | https://github.com/jespino/anillo/blob/901a84fd2b4fa909bc06e8bd76090457990576a7/anillo/utils/multipart.py#L102-L111 |
jespino/anillo | anillo/utils/multipart.py | parse_form_data | def parse_form_data(environ, charset='utf8', strict=False, **kw):
''' Parse form data from an environ dict and return a (forms, files) tuple.
Both tuple values are dictionaries with the form-field name as a key
(unicode) and lists as values (multiple values per key are possible).
The forms-d... | python | def parse_form_data(environ, charset='utf8', strict=False, **kw):
''' Parse form data from an environ dict and return a (forms, files) tuple.
Both tuple values are dictionaries with the form-field name as a key
(unicode) and lists as values (multiple values per key are possible).
The forms-d... | [
"def",
"parse_form_data",
"(",
"environ",
",",
"charset",
"=",
"'utf8'",
",",
"strict",
"=",
"False",
",",
"*",
"*",
"kw",
")",
":",
"forms",
",",
"files",
"=",
"MultiDict",
"(",
")",
",",
"MultiDict",
"(",
")",
"try",
":",
"if",
"environ",
".",
"g... | Parse form data from an environ dict and return a (forms, files) tuple.
Both tuple values are dictionaries with the form-field name as a key
(unicode) and lists as values (multiple values per key are possible).
The forms-dictionary contains form-field values as unicode strings.
The files... | [
"Parse",
"form",
"data",
"from",
"an",
"environ",
"dict",
"and",
"return",
"a",
"(",
"forms",
"files",
")",
"tuple",
".",
"Both",
"tuple",
"values",
"are",
"dictionaries",
"with",
"the",
"form",
"-",
"field",
"name",
"as",
"a",
"key",
"(",
"unicode",
"... | train | https://github.com/jespino/anillo/blob/901a84fd2b4fa909bc06e8bd76090457990576a7/anillo/utils/multipart.py#L381-L433 |
jespino/anillo | anillo/utils/multipart.py | MultipartParser.get | def get(self, name, default=None):
''' Return the first part with that name or a default value (None). '''
for part in self:
if name == part.name:
return part
return default | python | def get(self, name, default=None):
''' Return the first part with that name or a default value (None). '''
for part in self:
if name == part.name:
return part
return default | [
"def",
"get",
"(",
"self",
",",
"name",
",",
"default",
"=",
"None",
")",
":",
"for",
"part",
"in",
"self",
":",
"if",
"name",
"==",
"part",
".",
"name",
":",
"return",
"part",
"return",
"default"
] | Return the first part with that name or a default value (None). | [
"Return",
"the",
"first",
"part",
"with",
"that",
"name",
"or",
"a",
"default",
"value",
"(",
"None",
")",
"."
] | train | https://github.com/jespino/anillo/blob/901a84fd2b4fa909bc06e8bd76090457990576a7/anillo/utils/multipart.py#L201-L206 |
jespino/anillo | anillo/utils/multipart.py | MultipartParser._lineiter | def _lineiter(self):
''' Iterate over a binary file-like object line by line. Each line is
returned as a (line, line_ending) tuple. If the line does not fit
into self.buffer_size, line_ending is empty and the rest of the line
is returned with the next iteration.
'''
... | python | def _lineiter(self):
''' Iterate over a binary file-like object line by line. Each line is
returned as a (line, line_ending) tuple. If the line does not fit
into self.buffer_size, line_ending is empty and the rest of the line
is returned with the next iteration.
'''
... | [
"def",
"_lineiter",
"(",
"self",
")",
":",
"read",
"=",
"self",
".",
"stream",
".",
"read",
"maxread",
",",
"maxbuf",
"=",
"self",
".",
"content_length",
",",
"self",
".",
"buffer_size",
"buffer",
"=",
"b''",
"# buffer for the last (partial) line",
"while",
... | Iterate over a binary file-like object line by line. Each line is
returned as a (line, line_ending) tuple. If the line does not fit
into self.buffer_size, line_ending is empty and the rest of the line
is returned with the next iteration. | [
"Iterate",
"over",
"a",
"binary",
"file",
"-",
"like",
"object",
"line",
"by",
"line",
".",
"Each",
"line",
"is",
"returned",
"as",
"a",
"(",
"line",
"line_ending",
")",
"tuple",
".",
"If",
"the",
"line",
"does",
"not",
"fit",
"into",
"self",
".",
"b... | train | https://github.com/jespino/anillo/blob/901a84fd2b4fa909bc06e8bd76090457990576a7/anillo/utils/multipart.py#L212-L248 |
jespino/anillo | anillo/utils/multipart.py | MultipartPart.value | def value(self):
''' Data decoded with the specified charset '''
pos = self.file.tell()
self.file.seek(0)
val = self.file.read()
self.file.seek(pos)
return val.decode(self.charset) | python | def value(self):
''' Data decoded with the specified charset '''
pos = self.file.tell()
self.file.seek(0)
val = self.file.read()
self.file.seek(pos)
return val.decode(self.charset) | [
"def",
"value",
"(",
"self",
")",
":",
"pos",
"=",
"self",
".",
"file",
".",
"tell",
"(",
")",
"self",
".",
"file",
".",
"seek",
"(",
"0",
")",
"val",
"=",
"self",
".",
"file",
".",
"read",
"(",
")",
"self",
".",
"file",
".",
"seek",
"(",
"... | Data decoded with the specified charset | [
"Data",
"decoded",
"with",
"the",
"specified",
"charset"
] | train | https://github.com/jespino/anillo/blob/901a84fd2b4fa909bc06e8bd76090457990576a7/anillo/utils/multipart.py#L358-L364 |
kervi/kervi-devices | kervi/devices/displays/dummy_display_driver.py | DummyBitmapDisplayDriver.image | def image(self, image):
"""Set buffer to value of Python Imaging Library image. The image should
be in 1 bit mode and a size equal to the display size.
"""
if image.mode != '1':
raise ValueError('Image must be in mode 1.')
imwidth, imheight = image.size
if im... | python | def image(self, image):
"""Set buffer to value of Python Imaging Library image. The image should
be in 1 bit mode and a size equal to the display size.
"""
if image.mode != '1':
raise ValueError('Image must be in mode 1.')
imwidth, imheight = image.size
if im... | [
"def",
"image",
"(",
"self",
",",
"image",
")",
":",
"if",
"image",
".",
"mode",
"!=",
"'1'",
":",
"raise",
"ValueError",
"(",
"'Image must be in mode 1.'",
")",
"imwidth",
",",
"imheight",
"=",
"image",
".",
"size",
"if",
"imwidth",
"!=",
"self",
".",
... | Set buffer to value of Python Imaging Library image. The image should
be in 1 bit mode and a size equal to the display size. | [
"Set",
"buffer",
"to",
"value",
"of",
"Python",
"Imaging",
"Library",
"image",
".",
"The",
"image",
"should",
"be",
"in",
"1",
"bit",
"mode",
"and",
"a",
"size",
"equal",
"to",
"the",
"display",
"size",
"."
] | train | https://github.com/kervi/kervi-devices/blob/c6aaddc6da1d0bce0ea2b0c6eb8393ba10aefa56/kervi/devices/displays/dummy_display_driver.py#L105-L116 |
limodou/ido | ido/__init__.py | import_ | def import_(path):
"""
Import string format module, e.g. 'uliweb.orm' or an object
return module object and object
"""
if isinstance(path, str):
v = path.split(':')
if len(v) == 1:
x = path.rsplit('.', 1)
if len(x) == 2:
module, func = x
... | python | def import_(path):
"""
Import string format module, e.g. 'uliweb.orm' or an object
return module object and object
"""
if isinstance(path, str):
v = path.split(':')
if len(v) == 1:
x = path.rsplit('.', 1)
if len(x) == 2:
module, func = x
... | [
"def",
"import_",
"(",
"path",
")",
":",
"if",
"isinstance",
"(",
"path",
",",
"str",
")",
":",
"v",
"=",
"path",
".",
"split",
"(",
"':'",
")",
"if",
"len",
"(",
"v",
")",
"==",
"1",
":",
"x",
"=",
"path",
".",
"rsplit",
"(",
"'.'",
",",
"... | Import string format module, e.g. 'uliweb.orm' or an object
return module object and object | [
"Import",
"string",
"format",
"module",
"e",
".",
"g",
".",
"uliweb",
".",
"orm",
"or",
"an",
"object",
"return",
"module",
"object",
"and",
"object"
] | train | https://github.com/limodou/ido/blob/7fcf5c20b47993b6c16eb6007f77ad1c868a6d68/ido/__init__.py#L31-L53 |
limodou/ido | ido/__init__.py | BaseCommandMixin.collection_index | def collection_index(self):
"""
Collection index link to self.indexes, the order should be:
1. command argument
2. environment
3. default packages directory
"""
indexes = self.options.index
#add current directory to indexes
indexes.insert(0, os.ge... | python | def collection_index(self):
"""
Collection index link to self.indexes, the order should be:
1. command argument
2. environment
3. default packages directory
"""
indexes = self.options.index
#add current directory to indexes
indexes.insert(0, os.ge... | [
"def",
"collection_index",
"(",
"self",
")",
":",
"indexes",
"=",
"self",
".",
"options",
".",
"index",
"#add current directory to indexes",
"indexes",
".",
"insert",
"(",
"0",
",",
"os",
".",
"getcwd",
"(",
")",
")",
"if",
"'IDO_INDEXES'",
"in",
"os",
"."... | Collection index link to self.indexes, the order should be:
1. command argument
2. environment
3. default packages directory | [
"Collection",
"index",
"link",
"to",
"self",
".",
"indexes",
"the",
"order",
"should",
"be",
":",
"1",
".",
"command",
"argument",
"2",
".",
"environment",
"3",
".",
"default",
"packages",
"directory"
] | train | https://github.com/limodou/ido/blob/7fcf5c20b47993b6c16eb6007f77ad1c868a6d68/ido/__init__.py#L99-L114 |
limodou/ido | ido/__init__.py | CallCommand.execute | def execute(self):
"""
Given the command-line arguments, this figures out which subcommand is
being run, creates a parser appropriate to that command, and runs it.
"""
# Preprocess options to extract --settings and --pythonpath.
# These options could affect the commands t... | python | def execute(self):
"""
Given the command-line arguments, this figures out which subcommand is
being run, creates a parser appropriate to that command, and runs it.
"""
# Preprocess options to extract --settings and --pythonpath.
# These options could affect the commands t... | [
"def",
"execute",
"(",
"self",
")",
":",
"# Preprocess options to extract --settings and --pythonpath.",
"# These options could affect the commands that are available, so they",
"# must be processed early.",
"parser",
"=",
"NewOptionParser",
"(",
"prog",
"=",
"self",
".",
"prog_nam... | Given the command-line arguments, this figures out which subcommand is
being run, creates a parser appropriate to that command, and runs it. | [
"Given",
"the",
"command",
"-",
"line",
"arguments",
"this",
"figures",
"out",
"which",
"subcommand",
"is",
"being",
"run",
"creates",
"a",
"parser",
"appropriate",
"to",
"that",
"command",
"and",
"runs",
"it",
"."
] | train | https://github.com/limodou/ido/blob/7fcf5c20b47993b6c16eb6007f77ad1c868a6d68/ido/__init__.py#L544-L567 |
perimosocordiae/viztricks | viztricks/shims.py | _violinplot | def _violinplot(dataset, positions=None, vert=True, widths=0.5,
showmeans=False, showextrema=True, showmedians=False,
points=100, bw_method=None, ax=None):
'''Local version of the matplotlib violinplot.'''
if ax is None:
ax = plt.gca()
if positions is None:
positions = np.a... | python | def _violinplot(dataset, positions=None, vert=True, widths=0.5,
showmeans=False, showextrema=True, showmedians=False,
points=100, bw_method=None, ax=None):
'''Local version of the matplotlib violinplot.'''
if ax is None:
ax = plt.gca()
if positions is None:
positions = np.a... | [
"def",
"_violinplot",
"(",
"dataset",
",",
"positions",
"=",
"None",
",",
"vert",
"=",
"True",
",",
"widths",
"=",
"0.5",
",",
"showmeans",
"=",
"False",
",",
"showextrema",
"=",
"True",
",",
"showmedians",
"=",
"False",
",",
"points",
"=",
"100",
",",... | Local version of the matplotlib violinplot. | [
"Local",
"version",
"of",
"the",
"matplotlib",
"violinplot",
"."
] | train | https://github.com/perimosocordiae/viztricks/blob/bae2f8a9ce9278ce0197f8efc34cc4fef1dfe1eb/viztricks/shims.py#L25-L51 |
mbr/volatile | volatile/__init__.py | dir | def dir(suffix='', prefix='tmp', dir=None, force=True):
"""Create a temporary directory.
A contextmanager that creates and returns a temporary directory, cleaning
it up on exit.
The force option specifies whether or not the directory is removed
recursively. If set to `False` (the default is `True`... | python | def dir(suffix='', prefix='tmp', dir=None, force=True):
"""Create a temporary directory.
A contextmanager that creates and returns a temporary directory, cleaning
it up on exit.
The force option specifies whether or not the directory is removed
recursively. If set to `False` (the default is `True`... | [
"def",
"dir",
"(",
"suffix",
"=",
"''",
",",
"prefix",
"=",
"'tmp'",
",",
"dir",
"=",
"None",
",",
"force",
"=",
"True",
")",
":",
"name",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"suffix",
",",
"prefix",
",",
"dir",
")",
"try",
":",
"yield",
"name"... | Create a temporary directory.
A contextmanager that creates and returns a temporary directory, cleaning
it up on exit.
The force option specifies whether or not the directory is removed
recursively. If set to `False` (the default is `True`), only an empty
temporary directory will be removed. This ... | [
"Create",
"a",
"temporary",
"directory",
"."
] | train | https://github.com/mbr/volatile/blob/b526eda708e3c26b330d0f3f2a98c1f0feb8ec50/volatile/__init__.py#L10-L42 |
mbr/volatile | volatile/__init__.py | file | def file(mode='w+b', suffix='', prefix='tmp', dir=None, ignore_missing=False):
"""Create a temporary file.
A contextmanager that creates and returns a named temporary file and
removes it on exit. Differs from temporary file functions in
:mod:`tempfile` by not deleting the file once it is closed, making... | python | def file(mode='w+b', suffix='', prefix='tmp', dir=None, ignore_missing=False):
"""Create a temporary file.
A contextmanager that creates and returns a named temporary file and
removes it on exit. Differs from temporary file functions in
:mod:`tempfile` by not deleting the file once it is closed, making... | [
"def",
"file",
"(",
"mode",
"=",
"'w+b'",
",",
"suffix",
"=",
"''",
",",
"prefix",
"=",
"'tmp'",
",",
"dir",
"=",
"None",
",",
"ignore_missing",
"=",
"False",
")",
":",
"# note: bufsize is not supported in Python3, try to prevent problems",
"# stemming from in... | Create a temporary file.
A contextmanager that creates and returns a named temporary file and
removes it on exit. Differs from temporary file functions in
:mod:`tempfile` by not deleting the file once it is closed, making it safe
to write and close the file and then processing it with an external
p... | [
"Create",
"a",
"temporary",
"file",
"."
] | train | https://github.com/mbr/volatile/blob/b526eda708e3c26b330d0f3f2a98c1f0feb8ec50/volatile/__init__.py#L46-L86 |
mbr/volatile | volatile/__init__.py | unix_socket | def unix_socket(sock=None, socket_name='tmp.socket', close=True):
"""Create temporary unix socket.
Creates and binds a temporary unix socket that will be closed and removed
on exit.
:param sock: If not `None`, will not created a new unix socket, but bind
the passed in one instead.
... | python | def unix_socket(sock=None, socket_name='tmp.socket', close=True):
"""Create temporary unix socket.
Creates and binds a temporary unix socket that will be closed and removed
on exit.
:param sock: If not `None`, will not created a new unix socket, but bind
the passed in one instead.
... | [
"def",
"unix_socket",
"(",
"sock",
"=",
"None",
",",
"socket_name",
"=",
"'tmp.socket'",
",",
"close",
"=",
"True",
")",
":",
"sock",
"=",
"sock",
"or",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_UNIX",
",",
"socket",
".",
"SOCK_STREAM",
")",
"wi... | Create temporary unix socket.
Creates and binds a temporary unix socket that will be closed and removed
on exit.
:param sock: If not `None`, will not created a new unix socket, but bind
the passed in one instead.
:param socket_name: The name for the socket file (will be placed in a
... | [
"Create",
"temporary",
"unix",
"socket",
"."
] | train | https://github.com/mbr/volatile/blob/b526eda708e3c26b330d0f3f2a98c1f0feb8ec50/volatile/__init__.py#L90-L115 |
sbarham/dsrt | build/lib/dsrt/config/ConfigurationLoader.py | ConfigurationLoader.load_config | def load_config(self, path):
'''Load a configuration file; eventually, support dicts, .yaml, .csv, etc.'''
# if no path was provided, resort to defaults
if path == None:
print("Path to config was null; using defaults.")
return
if not os.path.exists(path):
... | python | def load_config(self, path):
'''Load a configuration file; eventually, support dicts, .yaml, .csv, etc.'''
# if no path was provided, resort to defaults
if path == None:
print("Path to config was null; using defaults.")
return
if not os.path.exists(path):
... | [
"def",
"load_config",
"(",
"self",
",",
"path",
")",
":",
"# if no path was provided, resort to defaults",
"if",
"path",
"==",
"None",
":",
"print",
"(",
"\"Path to config was null; using defaults.\"",
")",
"return",
"if",
"not",
"os",
".",
"path",
".",
"exists",
... | Load a configuration file; eventually, support dicts, .yaml, .csv, etc. | [
"Load",
"a",
"configuration",
"file",
";",
"eventually",
"support",
"dicts",
".",
"yaml",
".",
"csv",
"etc",
"."
] | train | https://github.com/sbarham/dsrt/blob/bc664739f2f52839461d3e72773b71146fd56a9a/build/lib/dsrt/config/ConfigurationLoader.py#L24-L54 |
sbarham/dsrt | build/lib/dsrt/config/ConfigurationLoader.py | ConfigurationLoader.merge_config | def merge_config(self, user_config):
'''
Take a dictionary of user preferences and use them to update the default
data, model, and conversation configurations.
'''
# provisioanlly update the default configurations with the user preferences
temp_data_config = copy.deepcop... | python | def merge_config(self, user_config):
'''
Take a dictionary of user preferences and use them to update the default
data, model, and conversation configurations.
'''
# provisioanlly update the default configurations with the user preferences
temp_data_config = copy.deepcop... | [
"def",
"merge_config",
"(",
"self",
",",
"user_config",
")",
":",
"# provisioanlly update the default configurations with the user preferences",
"temp_data_config",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
".",
"data_config",
")",
".",
"update",
"(",
"user_config",
")... | Take a dictionary of user preferences and use them to update the default
data, model, and conversation configurations. | [
"Take",
"a",
"dictionary",
"of",
"user",
"preferences",
"and",
"use",
"them",
"to",
"update",
"the",
"default",
"data",
"model",
"and",
"conversation",
"configurations",
"."
] | train | https://github.com/sbarham/dsrt/blob/bc664739f2f52839461d3e72773b71146fd56a9a/build/lib/dsrt/config/ConfigurationLoader.py#L56-L73 |
hwstovall/seaplane | seaplane/utils/which.py | which | def which(program):
"""
A python implementation of which.
https://stackoverflow.com/a/2969007
"""
path_ext = [""]
ext_list = None
if sys.platform == "win32":
ext_list = [ext.lower() for ext in os.environ["PATHEXT"].split(";")]
def is_exe(fpath):
exe = os.path.isfile(fp... | python | def which(program):
"""
A python implementation of which.
https://stackoverflow.com/a/2969007
"""
path_ext = [""]
ext_list = None
if sys.platform == "win32":
ext_list = [ext.lower() for ext in os.environ["PATHEXT"].split(";")]
def is_exe(fpath):
exe = os.path.isfile(fp... | [
"def",
"which",
"(",
"program",
")",
":",
"path_ext",
"=",
"[",
"\"\"",
"]",
"ext_list",
"=",
"None",
"if",
"sys",
".",
"platform",
"==",
"\"win32\"",
":",
"ext_list",
"=",
"[",
"ext",
".",
"lower",
"(",
")",
"for",
"ext",
"in",
"os",
".",
"environ... | A python implementation of which.
https://stackoverflow.com/a/2969007 | [
"A",
"python",
"implementation",
"of",
"which",
"."
] | train | https://github.com/hwstovall/seaplane/blob/6acb240b51afeead692cf720e15704fd9275907c/seaplane/utils/which.py#L6-L42 |
siemens/django-dingos | dingos/view_classes.py | ViewMethodMixin.get_user_data | def get_user_data(self):
"""
Extracts user data, either from user session or from
database (for each User, an InfoObject is used to
store data of a certain kind (e.g., user customization,
saved searches, etc.). If for a given user,
no InfoObject exists for a given type of... | python | def get_user_data(self):
"""
Extracts user data, either from user session or from
database (for each User, an InfoObject is used to
store data of a certain kind (e.g., user customization,
saved searches, etc.). If for a given user,
no InfoObject exists for a given type of... | [
"def",
"get_user_data",
"(",
"self",
")",
":",
"# Below, we retrieve user-specific data (user preferences, saved searches, etc.)",
"# We take this data from the session -- if it has already been",
"# loaded in the session. If not, then we load the data into the session first.",
"#",
"# Things ar... | Extracts user data, either from user session or from
database (for each User, an InfoObject is used to
store data of a certain kind (e.g., user customization,
saved searches, etc.). If for a given user,
no InfoObject exists for a given type of user-specific data,
the default data... | [
"Extracts",
"user",
"data",
"either",
"from",
"user",
"session",
"or",
"from",
"database",
"(",
"for",
"each",
"User",
"an",
"InfoObject",
"is",
"used",
"to",
"store",
"data",
"of",
"a",
"certain",
"kind",
"(",
"e",
".",
"g",
".",
"user",
"customization"... | train | https://github.com/siemens/django-dingos/blob/7154f75b06d2538568e2f2455a76f3d0db0b7d70/dingos/view_classes.py#L106-L200 |
siemens/django-dingos | dingos/view_classes.py | ViewMethodMixin._lookup_user_data | def _lookup_user_data(self,*args,**kwargs):
"""
Generic function for looking up values in
a user-specific dictionary. Use as follows::
_lookup_user_data('path','to','desired','value','in','dictionary',
default = <default value>,
... | python | def _lookup_user_data(self,*args,**kwargs):
"""
Generic function for looking up values in
a user-specific dictionary. Use as follows::
_lookup_user_data('path','to','desired','value','in','dictionary',
default = <default value>,
... | [
"def",
"_lookup_user_data",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"user_data",
"=",
"self",
".",
"get_user_data",
"(",
")",
"data_kind",
"=",
"kwargs",
".",
"get",
"(",
"'data_kind'",
",",
"'customization'",
")",
"try",
":",
... | Generic function for looking up values in
a user-specific dictionary. Use as follows::
_lookup_user_data('path','to','desired','value','in','dictionary',
default = <default value>,
data_kind = 'customization'/'saved_searches') | [
"Generic",
"function",
"for",
"looking",
"up",
"values",
"in",
"a",
"user",
"-",
"specific",
"dictionary",
".",
"Use",
"as",
"follows",
"::"
] | train | https://github.com/siemens/django-dingos/blob/7154f75b06d2538568e2f2455a76f3d0db0b7d70/dingos/view_classes.py#L203-L230 |
baguette-io/baguette-messaging | farine/connectors/sql/entrypoints.py | migrate | def migrate(module=None):
"""
Entrypoint to migrate the schema.
For the moment only create tables.
"""
if not module:
#Parsing
parser = argparse.ArgumentParser()
parser.add_argument('-s', '--service', type=str, help='Migrate the module', required=True,
... | python | def migrate(module=None):
"""
Entrypoint to migrate the schema.
For the moment only create tables.
"""
if not module:
#Parsing
parser = argparse.ArgumentParser()
parser.add_argument('-s', '--service', type=str, help='Migrate the module', required=True,
... | [
"def",
"migrate",
"(",
"module",
"=",
"None",
")",
":",
"if",
"not",
"module",
":",
"#Parsing",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"'-s'",
",",
"'--service'",
",",
"type",
"=",
"str",
",",
"h... | Entrypoint to migrate the schema.
For the moment only create tables. | [
"Entrypoint",
"to",
"migrate",
"the",
"schema",
".",
"For",
"the",
"moment",
"only",
"create",
"tables",
"."
] | train | https://github.com/baguette-io/baguette-messaging/blob/8d1c4707ea7eace8617fed2d97df2fcc9d0cdee1/farine/connectors/sql/entrypoints.py#L13-L34 |
inveniosoftware-attic/invenio-unapi | invenio_unapi/views.py | index | def index():
"""Handle /unapi set of pages."""
# Prepare mappings from configuration.
mapping = cfg['UNAPI_FORMAT_MAPPING']
names = {mapping[k]: k for k in mapping}
# Clean request arguments.
identifier = request.values.get('id', type=int)
format_ = request.values.get('format')
format_ =... | python | def index():
"""Handle /unapi set of pages."""
# Prepare mappings from configuration.
mapping = cfg['UNAPI_FORMAT_MAPPING']
names = {mapping[k]: k for k in mapping}
# Clean request arguments.
identifier = request.values.get('id', type=int)
format_ = request.values.get('format')
format_ =... | [
"def",
"index",
"(",
")",
":",
"# Prepare mappings from configuration.",
"mapping",
"=",
"cfg",
"[",
"'UNAPI_FORMAT_MAPPING'",
"]",
"names",
"=",
"{",
"mapping",
"[",
"k",
"]",
":",
"k",
"for",
"k",
"in",
"mapping",
"}",
"# Clean request arguments.",
"identifier... | Handle /unapi set of pages. | [
"Handle",
"/",
"unapi",
"set",
"of",
"pages",
"."
] | train | https://github.com/inveniosoftware-attic/invenio-unapi/blob/98286e9826f5f6525fbf9087339ca68d363e7ba0/invenio_unapi/views.py#L35-L58 |
wooga/play-deliver | playdeliver/playdeliver.py | execute | def execute(options):
"""execute the tool with given options."""
# Load the key in PKCS 12 format that you downloaded from the Google APIs
# Console when you created your Service account.
package_name = options['<package>']
source_directory = options['<output_dir>']
if options['upload'] is True... | python | def execute(options):
"""execute the tool with given options."""
# Load the key in PKCS 12 format that you downloaded from the Google APIs
# Console when you created your Service account.
package_name = options['<package>']
source_directory = options['<output_dir>']
if options['upload'] is True... | [
"def",
"execute",
"(",
"options",
")",
":",
"# Load the key in PKCS 12 format that you downloaded from the Google APIs",
"# Console when you created your Service account.",
"package_name",
"=",
"options",
"[",
"'<package>'",
"]",
"source_directory",
"=",
"options",
"[",
"'<output... | execute the tool with given options. | [
"execute",
"the",
"tool",
"with",
"given",
"options",
"."
] | train | https://github.com/wooga/play-deliver/blob/9de0f35376f5342720b3a90bd3ca296b1f3a3f4c/playdeliver/playdeliver.py#L20-L42 |
wooga/play-deliver | playdeliver/playdeliver.py | create_credentials | def create_credentials(credentials_file=None,
service_email=None,
service_key=None,
scope='https://www.googleapis.com/auth/androidpublisher'):
"""
Create Google credentials object.
If given credentials_file is None, try to retrieve file p... | python | def create_credentials(credentials_file=None,
service_email=None,
service_key=None,
scope='https://www.googleapis.com/auth/androidpublisher'):
"""
Create Google credentials object.
If given credentials_file is None, try to retrieve file p... | [
"def",
"create_credentials",
"(",
"credentials_file",
"=",
"None",
",",
"service_email",
"=",
"None",
",",
"service_key",
"=",
"None",
",",
"scope",
"=",
"'https://www.googleapis.com/auth/androidpublisher'",
")",
":",
"credentials",
"=",
"None",
"if",
"service_email",... | Create Google credentials object.
If given credentials_file is None, try to retrieve file path from environment
or look up file in homefolder. | [
"Create",
"Google",
"credentials",
"object",
"."
] | train | https://github.com/wooga/play-deliver/blob/9de0f35376f5342720b3a90bd3ca296b1f3a3f4c/playdeliver/playdeliver.py#L45-L79 |
roboogle/gtkmvc3 | gtkmvco/gtkmvc3/support/decorators.py | good_decorator | def good_decorator(decorator):
"""This decorator makes decorators behave well wrt to decorated
functions names, doc, etc."""
def new_decorator(f):
g = decorator(f)
g.__name__ = f.__name__
g.__doc__ = f.__doc__
g.__dict__.update(f.__dict__)
return g
new_d... | python | def good_decorator(decorator):
"""This decorator makes decorators behave well wrt to decorated
functions names, doc, etc."""
def new_decorator(f):
g = decorator(f)
g.__name__ = f.__name__
g.__doc__ = f.__doc__
g.__dict__.update(f.__dict__)
return g
new_d... | [
"def",
"good_decorator",
"(",
"decorator",
")",
":",
"def",
"new_decorator",
"(",
"f",
")",
":",
"g",
"=",
"decorator",
"(",
"f",
")",
"g",
".",
"__name__",
"=",
"f",
".",
"__name__",
"g",
".",
"__doc__",
"=",
"f",
".",
"__doc__",
"g",
".",
"__dict... | This decorator makes decorators behave well wrt to decorated
functions names, doc, etc. | [
"This",
"decorator",
"makes",
"decorators",
"behave",
"well",
"wrt",
"to",
"decorated",
"functions",
"names",
"doc",
"etc",
"."
] | train | https://github.com/roboogle/gtkmvc3/blob/63405fd8d2056be26af49103b13a8d5e57fe4dff/gtkmvco/gtkmvc3/support/decorators.py#L33-L47 |
roboogle/gtkmvc3 | gtkmvco/gtkmvc3/support/decorators.py | good_classmethod_decorator | def good_classmethod_decorator(decorator):
"""This decorator makes class method decorators behave well wrt
to decorated class method names, doc, etc."""
def new_decorator(cls, f):
g = decorator(cls, f)
g.__name__ = f.__name__
g.__doc__ = f.__doc__
g.__dict__.update(f.__dict_... | python | def good_classmethod_decorator(decorator):
"""This decorator makes class method decorators behave well wrt
to decorated class method names, doc, etc."""
def new_decorator(cls, f):
g = decorator(cls, f)
g.__name__ = f.__name__
g.__doc__ = f.__doc__
g.__dict__.update(f.__dict_... | [
"def",
"good_classmethod_decorator",
"(",
"decorator",
")",
":",
"def",
"new_decorator",
"(",
"cls",
",",
"f",
")",
":",
"g",
"=",
"decorator",
"(",
"cls",
",",
"f",
")",
"g",
".",
"__name__",
"=",
"f",
".",
"__name__",
"g",
".",
"__doc__",
"=",
"f",... | This decorator makes class method decorators behave well wrt
to decorated class method names, doc, etc. | [
"This",
"decorator",
"makes",
"class",
"method",
"decorators",
"behave",
"well",
"wrt",
"to",
"decorated",
"class",
"method",
"names",
"doc",
"etc",
"."
] | train | https://github.com/roboogle/gtkmvc3/blob/63405fd8d2056be26af49103b13a8d5e57fe4dff/gtkmvco/gtkmvc3/support/decorators.py#L50-L64 |
roboogle/gtkmvc3 | gtkmvco/gtkmvc3/support/decorators.py | good_decorator_accepting_args | def good_decorator_accepting_args(decorator):
"""This decorator makes decorators behave well wrt to decorated
functions names, doc, etc.
Differently from good_decorator, this accepts decorators possibly
receiving arguments and keyword arguments.
This decorato can be used indifferently with class ... | python | def good_decorator_accepting_args(decorator):
"""This decorator makes decorators behave well wrt to decorated
functions names, doc, etc.
Differently from good_decorator, this accepts decorators possibly
receiving arguments and keyword arguments.
This decorato can be used indifferently with class ... | [
"def",
"good_decorator_accepting_args",
"(",
"decorator",
")",
":",
"def",
"new_decorator",
"(",
"*",
"f",
",",
"*",
"*",
"k",
")",
":",
"g",
"=",
"decorator",
"(",
"*",
"f",
",",
"*",
"*",
"k",
")",
"if",
"1",
"==",
"len",
"(",
"f",
")",
"and",
... | This decorator makes decorators behave well wrt to decorated
functions names, doc, etc.
Differently from good_decorator, this accepts decorators possibly
receiving arguments and keyword arguments.
This decorato can be used indifferently with class methods and
functions. | [
"This",
"decorator",
"makes",
"decorators",
"behave",
"well",
"wrt",
"to",
"decorated",
"functions",
"names",
"doc",
"etc",
"."
] | train | https://github.com/roboogle/gtkmvc3/blob/63405fd8d2056be26af49103b13a8d5e57fe4dff/gtkmvco/gtkmvc3/support/decorators.py#L67-L90 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/addons/genesis/genesis.py | GenesisWin.setup_ui | def setup_ui(self, ):
"""Create the browsers and all necessary ui elements for the tool
:returns: None
:rtype: None
:raises: None
"""
w = QtGui.QWidget(self)
w.setLayout(self.central_vbox)
self.setCentralWidget(w)
releasetypes = [djadapter.RELEASE... | python | def setup_ui(self, ):
"""Create the browsers and all necessary ui elements for the tool
:returns: None
:rtype: None
:raises: None
"""
w = QtGui.QWidget(self)
w.setLayout(self.central_vbox)
self.setCentralWidget(w)
releasetypes = [djadapter.RELEASE... | [
"def",
"setup_ui",
"(",
"self",
",",
")",
":",
"w",
"=",
"QtGui",
".",
"QWidget",
"(",
"self",
")",
"w",
".",
"setLayout",
"(",
"self",
".",
"central_vbox",
")",
"self",
".",
"setCentralWidget",
"(",
"w",
")",
"releasetypes",
"=",
"[",
"djadapter",
"... | Create the browsers and all necessary ui elements for the tool
:returns: None
:rtype: None
:raises: None | [
"Create",
"the",
"browsers",
"and",
"all",
"necessary",
"ui",
"elements",
"for",
"the",
"tool"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/genesis/genesis.py#L77-L112 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/addons/genesis/genesis.py | GenesisWin.setup_icons | def setup_icons(self, ):
"""Set all icons on buttons
:returns: None
:rtype: None
:raises: None
"""
folder_icon = get_icon('glyphicons_144_folder_open.png', asicon=True)
self.asset_open_pb.setIcon(folder_icon)
self.shot_open_pb.setIcon(folder_icon)
... | python | def setup_icons(self, ):
"""Set all icons on buttons
:returns: None
:rtype: None
:raises: None
"""
folder_icon = get_icon('glyphicons_144_folder_open.png', asicon=True)
self.asset_open_pb.setIcon(folder_icon)
self.shot_open_pb.setIcon(folder_icon)
... | [
"def",
"setup_icons",
"(",
"self",
",",
")",
":",
"folder_icon",
"=",
"get_icon",
"(",
"'glyphicons_144_folder_open.png'",
",",
"asicon",
"=",
"True",
")",
"self",
".",
"asset_open_pb",
".",
"setIcon",
"(",
"folder_icon",
")",
"self",
".",
"shot_open_pb",
".",... | Set all icons on buttons
:returns: None
:rtype: None
:raises: None | [
"Set",
"all",
"icons",
"on",
"buttons"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/genesis/genesis.py#L114-L127 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/addons/genesis/genesis.py | GenesisWin.setup_signals | def setup_signals(self, ):
"""Connect the signals with the slots to make the ui functional
:returns: None
:rtype: None
:raises: None
"""
self.browser.shot_taskfile_sel_changed.connect(self.shot_taskfile_sel_changed)
self.browser.asset_taskfile_sel_changed.connect... | python | def setup_signals(self, ):
"""Connect the signals with the slots to make the ui functional
:returns: None
:rtype: None
:raises: None
"""
self.browser.shot_taskfile_sel_changed.connect(self.shot_taskfile_sel_changed)
self.browser.asset_taskfile_sel_changed.connect... | [
"def",
"setup_signals",
"(",
"self",
",",
")",
":",
"self",
".",
"browser",
".",
"shot_taskfile_sel_changed",
".",
"connect",
"(",
"self",
".",
"shot_taskfile_sel_changed",
")",
"self",
".",
"browser",
".",
"asset_taskfile_sel_changed",
".",
"connect",
"(",
"sel... | Connect the signals with the slots to make the ui functional
:returns: None
:rtype: None
:raises: None | [
"Connect",
"the",
"signals",
"with",
"the",
"slots",
"to",
"make",
"the",
"ui",
"functional"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/genesis/genesis.py#L129-L142 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/addons/genesis/genesis.py | GenesisWin.asset_taskfile_sel_changed | def asset_taskfile_sel_changed(self, tf):
"""Callback for when the version selection has changed
:param tf: the selected taskfileinfo
:type tf: :class:`TaskFileInfo` | None
:returns: None
:rtype: None
:raises: None
"""
self.asset_open_pb.setEnabled(bool(t... | python | def asset_taskfile_sel_changed(self, tf):
"""Callback for when the version selection has changed
:param tf: the selected taskfileinfo
:type tf: :class:`TaskFileInfo` | None
:returns: None
:rtype: None
:raises: None
"""
self.asset_open_pb.setEnabled(bool(t... | [
"def",
"asset_taskfile_sel_changed",
"(",
"self",
",",
"tf",
")",
":",
"self",
".",
"asset_open_pb",
".",
"setEnabled",
"(",
"bool",
"(",
"tf",
")",
")",
"# only allow new, when there is an asset. if there is an asset, there should always be a task",
"enablenew",
"=",
"bo... | Callback for when the version selection has changed
:param tf: the selected taskfileinfo
:type tf: :class:`TaskFileInfo` | None
:returns: None
:rtype: None
:raises: None | [
"Callback",
"for",
"when",
"the",
"version",
"selection",
"has",
"changed"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/genesis/genesis.py#L156-L171 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/addons/genesis/genesis.py | GenesisWin.shot_taskfile_sel_changed | def shot_taskfile_sel_changed(self, tf):
"""Callback for when the version selection has changed
:param tf: the selected taskfileinfo
:type tf: :class:`TaskFileInfo` | None
:returns: None
:rtype: None
:raises: None
"""
self.shot_open_pb.setEnabled(bool(tf)... | python | def shot_taskfile_sel_changed(self, tf):
"""Callback for when the version selection has changed
:param tf: the selected taskfileinfo
:type tf: :class:`TaskFileInfo` | None
:returns: None
:rtype: None
:raises: None
"""
self.shot_open_pb.setEnabled(bool(tf)... | [
"def",
"shot_taskfile_sel_changed",
"(",
"self",
",",
"tf",
")",
":",
"self",
".",
"shot_open_pb",
".",
"setEnabled",
"(",
"bool",
"(",
"tf",
")",
")",
"# only allow new, if the releasetype is work",
"# only allow new, if there is a shot. if there is a shot, there should alwa... | Callback for when the version selection has changed
:param tf: the selected taskfileinfo
:type tf: :class:`TaskFileInfo` | None
:returns: None
:rtype: None
:raises: None | [
"Callback",
"for",
"when",
"the",
"version",
"selection",
"has",
"changed"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/genesis/genesis.py#L173-L189 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/addons/genesis/genesis.py | GenesisWin.update_descriptor_le | def update_descriptor_le(self, lineedit, tf):
"""Update the given line edit to show the descriptor that is stored in the index
:param lineedit: the line edit to update with the descriptor
:type lineedit: QLineEdit
:param tf: the selected taskfileinfo
:type tf: :class:`TaskFileIn... | python | def update_descriptor_le(self, lineedit, tf):
"""Update the given line edit to show the descriptor that is stored in the index
:param lineedit: the line edit to update with the descriptor
:type lineedit: QLineEdit
:param tf: the selected taskfileinfo
:type tf: :class:`TaskFileIn... | [
"def",
"update_descriptor_le",
"(",
"self",
",",
"lineedit",
",",
"tf",
")",
":",
"if",
"tf",
":",
"descriptor",
"=",
"tf",
".",
"descriptor",
"lineedit",
".",
"setText",
"(",
"descriptor",
")",
"else",
":",
"lineedit",
".",
"setText",
"(",
"\"\"",
")"
] | Update the given line edit to show the descriptor that is stored in the index
:param lineedit: the line edit to update with the descriptor
:type lineedit: QLineEdit
:param tf: the selected taskfileinfo
:type tf: :class:`TaskFileInfo` | None
:returns: None
:rtype: None
... | [
"Update",
"the",
"given",
"line",
"edit",
"to",
"show",
"the",
"descriptor",
"that",
"is",
"stored",
"in",
"the",
"index"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/genesis/genesis.py#L191-L206 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/addons/genesis/genesis.py | GenesisWin.shot_open_callback | def shot_open_callback(self, *args, **kwargs):
"""Callback for the shot open button
:returns: None
:rtype: None
:raises: None
"""
tf = self.browser.get_current_selection(1)
if not tf:
return
if not os.path.exists(tf.path):
msg = 'T... | python | def shot_open_callback(self, *args, **kwargs):
"""Callback for the shot open button
:returns: None
:rtype: None
:raises: None
"""
tf = self.browser.get_current_selection(1)
if not tf:
return
if not os.path.exists(tf.path):
msg = 'T... | [
"def",
"shot_open_callback",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"tf",
"=",
"self",
".",
"browser",
".",
"get_current_selection",
"(",
"1",
")",
"if",
"not",
"tf",
":",
"return",
"if",
"not",
"os",
".",
"path",
".",
"e... | Callback for the shot open button
:returns: None
:rtype: None
:raises: None | [
"Callback",
"for",
"the",
"shot",
"open",
"button"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/genesis/genesis.py#L217-L235 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/addons/genesis/genesis.py | GenesisWin.asset_open_callback | def asset_open_callback(self, *args, **kwargs):
"""Callback for the shot open button
:returns: None
:rtype: None
:raises: None
"""
tf = self.browser.get_current_selection(0)
if not tf:
return
if not os.path.exists(tf.path):
msg = '... | python | def asset_open_callback(self, *args, **kwargs):
"""Callback for the shot open button
:returns: None
:rtype: None
:raises: None
"""
tf = self.browser.get_current_selection(0)
if not tf:
return
if not os.path.exists(tf.path):
msg = '... | [
"def",
"asset_open_callback",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"tf",
"=",
"self",
".",
"browser",
".",
"get_current_selection",
"(",
"0",
")",
"if",
"not",
"tf",
":",
"return",
"if",
"not",
"os",
".",
"path",
".",
"... | Callback for the shot open button
:returns: None
:rtype: None
:raises: None | [
"Callback",
"for",
"the",
"shot",
"open",
"button"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/genesis/genesis.py#L237-L255 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/addons/genesis/genesis.py | GenesisWin.shot_save_callback | def shot_save_callback(self, *args, **kwargs):
"""Callback for the shot open button
:returns: None
:rtype: None
:raises: None
"""
tasksel = self.browser.shotbrws.selected_indexes(2)
if not tasksel or not tasksel[0].isValid():
self.statusbar.showMessag... | python | def shot_save_callback(self, *args, **kwargs):
"""Callback for the shot open button
:returns: None
:rtype: None
:raises: None
"""
tasksel = self.browser.shotbrws.selected_indexes(2)
if not tasksel or not tasksel[0].isValid():
self.statusbar.showMessag... | [
"def",
"shot_save_callback",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"tasksel",
"=",
"self",
".",
"browser",
".",
"shotbrws",
".",
"selected_indexes",
"(",
"2",
")",
"if",
"not",
"tasksel",
"or",
"not",
"tasksel",
"[",
"0",
... | Callback for the shot open button
:returns: None
:rtype: None
:raises: None | [
"Callback",
"for",
"the",
"shot",
"open",
"button"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/genesis/genesis.py#L257-L278 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/addons/genesis/genesis.py | GenesisWin.asset_save_callback | def asset_save_callback(self, *args, **kwargs):
"""Callback for the shot open button
:returns: None
:rtype: None
:raises: None
"""
tasksel = self.browser.assetbrws.selected_indexes(2)
if not tasksel or not tasksel[0].isValid():
self.statusbar.showMess... | python | def asset_save_callback(self, *args, **kwargs):
"""Callback for the shot open button
:returns: None
:rtype: None
:raises: None
"""
tasksel = self.browser.assetbrws.selected_indexes(2)
if not tasksel or not tasksel[0].isValid():
self.statusbar.showMess... | [
"def",
"asset_save_callback",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"tasksel",
"=",
"self",
".",
"browser",
".",
"assetbrws",
".",
"selected_indexes",
"(",
"2",
")",
"if",
"not",
"tasksel",
"or",
"not",
"tasksel",
"[",
"0",
... | Callback for the shot open button
:returns: None
:rtype: None
:raises: None | [
"Callback",
"for",
"the",
"shot",
"open",
"button"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/genesis/genesis.py#L280-L301 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/addons/genesis/genesis.py | GenesisWin._save_tfi | def _save_tfi(self, tfi, asset=False):
"""Save currently open scene with the information in the given taskfile info
:param tfi: taskfile info
:type tfi: :class:`TaskFileInfo`
:returns: None
:rtype: None
:raises: None
"""
jbfile = JB_File(tfi)
self... | python | def _save_tfi(self, tfi, asset=False):
"""Save currently open scene with the information in the given taskfile info
:param tfi: taskfile info
:type tfi: :class:`TaskFileInfo`
:returns: None
:rtype: None
:raises: None
"""
jbfile = JB_File(tfi)
self... | [
"def",
"_save_tfi",
"(",
"self",
",",
"tfi",
",",
"asset",
"=",
"False",
")",
":",
"jbfile",
"=",
"JB_File",
"(",
"tfi",
")",
"self",
".",
"create_dir",
"(",
"jbfile",
")",
"tf",
",",
"note",
"=",
"self",
".",
"create_db_entry",
"(",
"tfi",
")",
"t... | Save currently open scene with the information in the given taskfile info
:param tfi: taskfile info
:type tfi: :class:`TaskFileInfo`
:returns: None
:rtype: None
:raises: None | [
"Save",
"currently",
"open",
"scene",
"with",
"the",
"information",
"in",
"the",
"given",
"taskfile",
"info"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/genesis/genesis.py#L303-L333 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/addons/genesis/genesis.py | GenesisWin.create_dir | def create_dir(self, jbfile):
"""Create a dir for the given dirfile and display an error message, if it fails.
:param jbfile: the jb file to make the directory for
:type jbfile: class:`JB_File`
:returns: None
:rtype: None
:raises: None
"""
try:
... | python | def create_dir(self, jbfile):
"""Create a dir for the given dirfile and display an error message, if it fails.
:param jbfile: the jb file to make the directory for
:type jbfile: class:`JB_File`
:returns: None
:rtype: None
:raises: None
"""
try:
... | [
"def",
"create_dir",
"(",
"self",
",",
"jbfile",
")",
":",
"try",
":",
"jbfile",
".",
"create_directory",
"(",
")",
"except",
"os",
".",
"error",
":",
"self",
".",
"statusbar",
".",
"showMessage",
"(",
"'Could not create path: %s'",
"%",
"jbfile",
".",
"ge... | Create a dir for the given dirfile and display an error message, if it fails.
:param jbfile: the jb file to make the directory for
:type jbfile: class:`JB_File`
:returns: None
:rtype: None
:raises: None | [
"Create",
"a",
"dir",
"for",
"the",
"given",
"dirfile",
"and",
"display",
"an",
"error",
"message",
"if",
"it",
"fails",
"."
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/genesis/genesis.py#L335-L347 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/addons/genesis/genesis.py | GenesisWin.check_selection_for_save | def check_selection_for_save(self, task, releasetype, descriptor):
"""Emit warnings if the descriptor is None or the current file
is of a different task.
:param task: the selected task
:type task: :class:`djadapter.models.Task`
:param releasetype: the releasetype to save (probab... | python | def check_selection_for_save(self, task, releasetype, descriptor):
"""Emit warnings if the descriptor is None or the current file
is of a different task.
:param task: the selected task
:type task: :class:`djadapter.models.Task`
:param releasetype: the releasetype to save (probab... | [
"def",
"check_selection_for_save",
"(",
"self",
",",
"task",
",",
"releasetype",
",",
"descriptor",
")",
":",
"if",
"not",
"descriptor",
":",
"self",
".",
"statusbar",
".",
"showMessage",
"(",
"\"Please provide a descriptor!\"",
")",
"return",
"False",
"try",
":... | Emit warnings if the descriptor is None or the current file
is of a different task.
:param task: the selected task
:type task: :class:`djadapter.models.Task`
:param releasetype: the releasetype to save (probably work)
:type releasetype: str
:param descriptor: the descrip... | [
"Emit",
"warnings",
"if",
"the",
"descriptor",
"is",
"None",
"or",
"the",
"current",
"file",
"is",
"of",
"a",
"different",
"task",
"."
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/genesis/genesis.py#L414-L443 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/addons/genesis/genesis.py | GenesisWin.create_db_entry | def create_db_entry(self, tfi):
"""Create a db entry for the given task file info
:param tfi: the info for a TaskFile entry in the db
:type tfi: :class:`jukeboxcore.filesys.TaskFileInfo`
:returns: the created taskfile and note
:rtype: tuple
:raises: ValidationError
... | python | def create_db_entry(self, tfi):
"""Create a db entry for the given task file info
:param tfi: the info for a TaskFile entry in the db
:type tfi: :class:`jukeboxcore.filesys.TaskFileInfo`
:returns: the created taskfile and note
:rtype: tuple
:raises: ValidationError
... | [
"def",
"create_db_entry",
"(",
"self",
",",
"tfi",
")",
":",
"if",
"tfi",
".",
"task",
".",
"department",
".",
"assetflag",
":",
"comment",
"=",
"self",
".",
"asset_comment_pte",
".",
"toPlainText",
"(",
")",
"else",
":",
"comment",
"=",
"self",
".",
"... | Create a db entry for the given task file info
:param tfi: the info for a TaskFile entry in the db
:type tfi: :class:`jukeboxcore.filesys.TaskFileInfo`
:returns: the created taskfile and note
:rtype: tuple
:raises: ValidationError | [
"Create",
"a",
"db",
"entry",
"for",
"the",
"given",
"task",
"file",
"info"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/genesis/genesis.py#L445-L458 |
JukeboxPipeline/jukebox-core | src/jukeboxcore/addons/genesis/genesis.py | GenesisWin.closeEvent | def closeEvent(self, event):
"""Send last file signal on close event
:param event: The close event
:type event:
:returns: None
:rtype: None
:raises: None
"""
lf = self.browser.get_current_selection()
if lf:
self.last_file.emit(lf)
... | python | def closeEvent(self, event):
"""Send last file signal on close event
:param event: The close event
:type event:
:returns: None
:rtype: None
:raises: None
"""
lf = self.browser.get_current_selection()
if lf:
self.last_file.emit(lf)
... | [
"def",
"closeEvent",
"(",
"self",
",",
"event",
")",
":",
"lf",
"=",
"self",
".",
"browser",
".",
"get_current_selection",
"(",
")",
"if",
"lf",
":",
"self",
".",
"last_file",
".",
"emit",
"(",
"lf",
")",
"return",
"super",
"(",
"GenesisWin",
",",
"s... | Send last file signal on close event
:param event: The close event
:type event:
:returns: None
:rtype: None
:raises: None | [
"Send",
"last",
"file",
"signal",
"on",
"close",
"event"
] | train | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/addons/genesis/genesis.py#L460-L472 |
wooga/play-deliver | playdeliver/listing.py | upload | def upload(client, source_dir):
"""Upload listing files in source_dir. folder herachy."""
print('')
print('upload store listings')
print('---------------------')
listings_folder = os.path.join(source_dir, 'listings')
langfolders = filter(os.path.isdir, list_dir_abspath(listings_folder))
for... | python | def upload(client, source_dir):
"""Upload listing files in source_dir. folder herachy."""
print('')
print('upload store listings')
print('---------------------')
listings_folder = os.path.join(source_dir, 'listings')
langfolders = filter(os.path.isdir, list_dir_abspath(listings_folder))
for... | [
"def",
"upload",
"(",
"client",
",",
"source_dir",
")",
":",
"print",
"(",
"''",
")",
"print",
"(",
"'upload store listings'",
")",
"print",
"(",
"'---------------------'",
")",
"listings_folder",
"=",
"os",
".",
"path",
".",
"join",
"(",
"source_dir",
",",
... | Upload listing files in source_dir. folder herachy. | [
"Upload",
"listing",
"files",
"in",
"source_dir",
".",
"folder",
"herachy",
"."
] | train | https://github.com/wooga/play-deliver/blob/9de0f35376f5342720b3a90bd3ca296b1f3a3f4c/playdeliver/listing.py#L8-L24 |
wooga/play-deliver | playdeliver/listing.py | download | def download(client, target_dir):
"""Download listing files from play and saves them into folder herachy."""
print('')
print('download store listings')
print('---------------------')
listings = client.list('listings')
for listing in listings:
path = os.path.join(target_dir, 'listings', l... | python | def download(client, target_dir):
"""Download listing files from play and saves them into folder herachy."""
print('')
print('download store listings')
print('---------------------')
listings = client.list('listings')
for listing in listings:
path = os.path.join(target_dir, 'listings', l... | [
"def",
"download",
"(",
"client",
",",
"target_dir",
")",
":",
"print",
"(",
"''",
")",
"print",
"(",
"'download store listings'",
")",
"print",
"(",
"'---------------------'",
")",
"listings",
"=",
"client",
".",
"list",
"(",
"'listings'",
")",
"for",
"list... | Download listing files from play and saves them into folder herachy. | [
"Download",
"listing",
"files",
"from",
"play",
"and",
"saves",
"them",
"into",
"folder",
"herachy",
"."
] | train | https://github.com/wooga/play-deliver/blob/9de0f35376f5342720b3a90bd3ca296b1f3a3f4c/playdeliver/listing.py#L27-L40 |
twneale/hercules | hercules/dict.py | DictFilterMixin.filter | def filter(self, **kwargs):
'''Assumes all the dict's items are hashable.
'''
# So we don't return anything more than once.
yielded = set()
dunder = '__'
filter_items = set()
for k, v in kwargs.items():
if dunder in k:
k, op = k.split(... | python | def filter(self, **kwargs):
'''Assumes all the dict's items are hashable.
'''
# So we don't return anything more than once.
yielded = set()
dunder = '__'
filter_items = set()
for k, v in kwargs.items():
if dunder in k:
k, op = k.split(... | [
"def",
"filter",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# So we don't return anything more than once.",
"yielded",
"=",
"set",
"(",
")",
"dunder",
"=",
"'__'",
"filter_items",
"=",
"set",
"(",
")",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"it... | Assumes all the dict's items are hashable. | [
"Assumes",
"all",
"the",
"dict",
"s",
"items",
"are",
"hashable",
"."
] | train | https://github.com/twneale/hercules/blob/cd61582ef7e593093e9b28b56798df4203d1467a/hercules/dict.py#L53-L81 |
samuel-phan/mssh-copy-id | msshcopyid/cli.py | Main.copy_ssh_keys_to_hosts | def copy_ssh_keys_to_hosts(self, hosts, known_hosts=DEFAULT_KNOWN_HOSTS, dry=False):
"""
Copy the SSH keys to the given hosts.
:param hosts: the list of `Host` objects to copy the SSH keys to.
:param known_hosts: the `known_hosts` file to store the SSH public keys.
:param dry: p... | python | def copy_ssh_keys_to_hosts(self, hosts, known_hosts=DEFAULT_KNOWN_HOSTS, dry=False):
"""
Copy the SSH keys to the given hosts.
:param hosts: the list of `Host` objects to copy the SSH keys to.
:param known_hosts: the `known_hosts` file to store the SSH public keys.
:param dry: p... | [
"def",
"copy_ssh_keys_to_hosts",
"(",
"self",
",",
"hosts",
",",
"known_hosts",
"=",
"DEFAULT_KNOWN_HOSTS",
",",
"dry",
"=",
"False",
")",
":",
"exceptions",
"=",
"[",
"]",
"# list of `CopySSHKeyError`",
"for",
"host",
"in",
"hosts",
":",
"logger",
".",
"info"... | Copy the SSH keys to the given hosts.
:param hosts: the list of `Host` objects to copy the SSH keys to.
:param known_hosts: the `known_hosts` file to store the SSH public keys.
:param dry: perform a dry run.
:raise msshcopyid.errors.CopySSHKeysError: | [
"Copy",
"the",
"SSH",
"keys",
"to",
"the",
"given",
"hosts",
"."
] | train | https://github.com/samuel-phan/mssh-copy-id/blob/59c50eabb74c4e0eeb729266df57c285e6661b0b/msshcopyid/cli.py#L175-L196 |
samuel-phan/mssh-copy-id | msshcopyid/cli.py | Main.copy_ssh_keys_to_host | def copy_ssh_keys_to_host(self, host, known_hosts=DEFAULT_KNOWN_HOSTS):
"""
Copy the SSH keys to the given host.
:param host: the `Host` object to copy the SSH keys to.
:param known_hosts: the `known_hosts` file to store the SSH public keys.
:raise paramiko.ssh_exception.Authent... | python | def copy_ssh_keys_to_host(self, host, known_hosts=DEFAULT_KNOWN_HOSTS):
"""
Copy the SSH keys to the given host.
:param host: the `Host` object to copy the SSH keys to.
:param known_hosts: the `known_hosts` file to store the SSH public keys.
:raise paramiko.ssh_exception.Authent... | [
"def",
"copy_ssh_keys_to_host",
"(",
"self",
",",
"host",
",",
"known_hosts",
"=",
"DEFAULT_KNOWN_HOSTS",
")",
":",
"password",
"=",
"host",
".",
"password",
"or",
"self",
".",
"sshcopyid",
".",
"default_password",
"try",
":",
"self",
".",
"sshcopyid",
".",
... | Copy the SSH keys to the given host.
:param host: the `Host` object to copy the SSH keys to.
:param known_hosts: the `known_hosts` file to store the SSH public keys.
:raise paramiko.ssh_exception.AuthenticationException: | [
"Copy",
"the",
"SSH",
"keys",
"to",
"the",
"given",
"host",
"."
] | train | https://github.com/samuel-phan/mssh-copy-id/blob/59c50eabb74c4e0eeb729266df57c285e6661b0b/msshcopyid/cli.py#L198-L222 |
laco/python-hexconnector | hexconnector/connector.py | HexConnector.call_fn | def call_fn(self, what, *args, **kwargs):
""" Lazy call init_adapter then call the function """
logger.debug('f_{0}:{1}{2}({3})'.format(
self.call_stack_level,
' ' * 4 * self.call_stack_level,
what,
arguments_as_string(args, kwargs)))
port, fn_name... | python | def call_fn(self, what, *args, **kwargs):
""" Lazy call init_adapter then call the function """
logger.debug('f_{0}:{1}{2}({3})'.format(
self.call_stack_level,
' ' * 4 * self.call_stack_level,
what,
arguments_as_string(args, kwargs)))
port, fn_name... | [
"def",
"call_fn",
"(",
"self",
",",
"what",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"logger",
".",
"debug",
"(",
"'f_{0}:{1}{2}({3})'",
".",
"format",
"(",
"self",
".",
"call_stack_level",
",",
"' '",
"*",
"4",
"*",
"self",
".",
"call_st... | Lazy call init_adapter then call the function | [
"Lazy",
"call",
"init_adapter",
"then",
"call",
"the",
"function"
] | train | https://github.com/laco/python-hexconnector/blob/99d7bc7a768252e9622c5dc6b1518fc91e08561b/hexconnector/connector.py#L62-L73 |
demosdemon/format-pipfile | ci/appveyor-download.py | unpack_zipfile | def unpack_zipfile(filename):
"""Unpack a zipfile, using the names in the zip."""
with open(filename, "rb") as fzip:
z = zipfile.ZipFile(fzip)
for name in z.namelist():
print((" extracting {}".format(name)))
ensure_dirs(name)
z.extract(name) | python | def unpack_zipfile(filename):
"""Unpack a zipfile, using the names in the zip."""
with open(filename, "rb") as fzip:
z = zipfile.ZipFile(fzip)
for name in z.namelist():
print((" extracting {}".format(name)))
ensure_dirs(name)
z.extract(name) | [
"def",
"unpack_zipfile",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"\"rb\"",
")",
"as",
"fzip",
":",
"z",
"=",
"zipfile",
".",
"ZipFile",
"(",
"fzip",
")",
"for",
"name",
"in",
"z",
".",
"namelist",
"(",
")",
":",
"print",
"(... | Unpack a zipfile, using the names in the zip. | [
"Unpack",
"a",
"zipfile",
"using",
"the",
"names",
"in",
"the",
"zip",
"."
] | train | https://github.com/demosdemon/format-pipfile/blob/f95162c49d8fc13153080ddb11ac5a5dcd4d2e7c/ci/appveyor-download.py#L95-L102 |
praekelt/panya-music | music/models.py | Track.get_primary_contributors | def get_primary_contributors(self, permitted=True):
"""
Returns a list of primary contributors, with primary being defined as those contributors that have the highest role assigned(in terms of priority). When permitted is set to True only permitted contributors are returned.
"""
primary_... | python | def get_primary_contributors(self, permitted=True):
"""
Returns a list of primary contributors, with primary being defined as those contributors that have the highest role assigned(in terms of priority). When permitted is set to True only permitted contributors are returned.
"""
primary_... | [
"def",
"get_primary_contributors",
"(",
"self",
",",
"permitted",
"=",
"True",
")",
":",
"primary_credits",
"=",
"[",
"]",
"credits",
"=",
"self",
".",
"credits",
".",
"exclude",
"(",
"role",
"=",
"None",
")",
".",
"order_by",
"(",
"'role'",
")",
"if",
... | Returns a list of primary contributors, with primary being defined as those contributors that have the highest role assigned(in terms of priority). When permitted is set to True only permitted contributors are returned. | [
"Returns",
"a",
"list",
"of",
"primary",
"contributors",
"with",
"primary",
"being",
"defined",
"as",
"those",
"contributors",
"that",
"have",
"the",
"highest",
"role",
"assigned",
"(",
"in",
"terms",
"of",
"priority",
")",
".",
"When",
"permitted",
"is",
"s... | train | https://github.com/praekelt/panya-music/blob/9300b1866bc33178e721b6de4771ba866bfc4b11/music/models.py#L77-L97 |
cyrus-/cypy | cypy/__init__.py | prog_iter | def prog_iter(bounded_iterable, delta=0.01, line_size=50):
'''Wraps the provided sequence with an iterator that tracks its progress
on the console.
>>> for i in prog_iter(xrange(100)): pass
..................................................
................................................ | python | def prog_iter(bounded_iterable, delta=0.01, line_size=50):
'''Wraps the provided sequence with an iterator that tracks its progress
on the console.
>>> for i in prog_iter(xrange(100)): pass
..................................................
................................................ | [
"def",
"prog_iter",
"(",
"bounded_iterable",
",",
"delta",
"=",
"0.01",
",",
"line_size",
"=",
"50",
")",
":",
"# TODO: Technically, this should have a __len__.",
"global",
"_prog_iterin_loop",
"if",
"not",
"_prog_iterin_loop",
":",
"startTime",
"=",
"_time",
".",
"... | Wraps the provided sequence with an iterator that tracks its progress
on the console.
>>> for i in prog_iter(xrange(100)): pass
..................................................
..................................................
(0.000331163406372 s)
More specifical... | [
"Wraps",
"the",
"provided",
"sequence",
"with",
"an",
"iterator",
"that",
"tracks",
"its",
"progress",
"on",
"the",
"console",
"."
] | train | https://github.com/cyrus-/cypy/blob/04bb59e91fa314e8cf987743189c77a9b6bc371d/cypy/__init__.py#L210-L252 |
cyrus-/cypy | cypy/__init__.py | include | def include(gset, elem, value=True):
"""Do whatever it takes to make ``elem in gset`` true.
>>> L, S, D = [ ], set(), { }
>>> include(L, "Lucy"); include(S, "Sky"); include(D, "Diamonds");
>>> print L, S, D
['Lucy'] set(['Sky']) {'Diamonds': True}
Works for sets (using ``add``)... | python | def include(gset, elem, value=True):
"""Do whatever it takes to make ``elem in gset`` true.
>>> L, S, D = [ ], set(), { }
>>> include(L, "Lucy"); include(S, "Sky"); include(D, "Diamonds");
>>> print L, S, D
['Lucy'] set(['Sky']) {'Diamonds': True}
Works for sets (using ``add``)... | [
"def",
"include",
"(",
"gset",
",",
"elem",
",",
"value",
"=",
"True",
")",
":",
"add",
"=",
"getattr",
"(",
"gset",
",",
"'add'",
",",
"None",
")",
"# sets",
"if",
"add",
"is",
"None",
":",
"add",
"=",
"getattr",
"(",
"gset",
",",
"'append'",
",... | Do whatever it takes to make ``elem in gset`` true.
>>> L, S, D = [ ], set(), { }
>>> include(L, "Lucy"); include(S, "Sky"); include(D, "Diamonds");
>>> print L, S, D
['Lucy'] set(['Sky']) {'Diamonds': True}
Works for sets (using ``add``), lists (using ``append``) and dicts (using
... | [
"Do",
"whatever",
"it",
"takes",
"to",
"make",
"elem",
"in",
"gset",
"true",
"."
] | train | https://github.com/cyrus-/cypy/blob/04bb59e91fa314e8cf987743189c77a9b6bc371d/cypy/__init__.py#L268-L291 |
cyrus-/cypy | cypy/__init__.py | include_many | def include_many(gset, elems, truth_value=True):
"""Do whatever it takes to make ``elem in gset`` true for each elem in ``elems``.
See :func:`include`.
"""
extend = getattr(gset, 'extend', None)
if extend is not None:
extend(elems)
elif hasattr(gset, '__setitem__'):
gset.upd... | python | def include_many(gset, elems, truth_value=True):
"""Do whatever it takes to make ``elem in gset`` true for each elem in ``elems``.
See :func:`include`.
"""
extend = getattr(gset, 'extend', None)
if extend is not None:
extend(elems)
elif hasattr(gset, '__setitem__'):
gset.upd... | [
"def",
"include_many",
"(",
"gset",
",",
"elems",
",",
"truth_value",
"=",
"True",
")",
":",
"extend",
"=",
"getattr",
"(",
"gset",
",",
"'extend'",
",",
"None",
")",
"if",
"extend",
"is",
"not",
"None",
":",
"extend",
"(",
"elems",
")",
"elif",
"has... | Do whatever it takes to make ``elem in gset`` true for each elem in ``elems``.
See :func:`include`. | [
"Do",
"whatever",
"it",
"takes",
"to",
"make",
"elem",
"in",
"gset",
"true",
"for",
"each",
"elem",
"in",
"elems",
".",
"See",
":",
"func",
":",
"include",
"."
] | train | https://github.com/cyrus-/cypy/blob/04bb59e91fa314e8cf987743189c77a9b6bc371d/cypy/__init__.py#L293-L306 |
cyrus-/cypy | cypy/__init__.py | remove_once | def remove_once(gset, elem):
"""Remove the element from a set, lists or dict.
>>> L = ["Lucy"]; S = set(["Sky"]); D = { "Diamonds": True };
>>> remove_once(L, "Lucy"); remove_once(S, "Sky"); remove_once(D, "Diamonds");
>>> print L, S, D
[] set([]) {}
Returns the element if ... | python | def remove_once(gset, elem):
"""Remove the element from a set, lists or dict.
>>> L = ["Lucy"]; S = set(["Sky"]); D = { "Diamonds": True };
>>> remove_once(L, "Lucy"); remove_once(S, "Sky"); remove_once(D, "Diamonds");
>>> print L, S, D
[] set([]) {}
Returns the element if ... | [
"def",
"remove_once",
"(",
"gset",
",",
"elem",
")",
":",
"remove",
"=",
"getattr",
"(",
"gset",
",",
"'remove'",
",",
"None",
")",
"if",
"remove",
"is",
"not",
"None",
":",
"remove",
"(",
"elem",
")",
"else",
":",
"del",
"gset",
"[",
"elem",
"]",
... | Remove the element from a set, lists or dict.
>>> L = ["Lucy"]; S = set(["Sky"]); D = { "Diamonds": True };
>>> remove_once(L, "Lucy"); remove_once(S, "Sky"); remove_once(D, "Diamonds");
>>> print L, S, D
[] set([]) {}
Returns the element if it was removed. Raises one of the ex... | [
"Remove",
"the",
"element",
"from",
"a",
"set",
"lists",
"or",
"dict",
".",
">>>",
"L",
"=",
"[",
"Lucy",
"]",
";",
"S",
"=",
"set",
"(",
"[",
"Sky",
"]",
")",
";",
"D",
"=",
"{",
"Diamonds",
":",
"True",
"}",
";",
">>>",
"remove_once",
"(",
... | train | https://github.com/cyrus-/cypy/blob/04bb59e91fa314e8cf987743189c77a9b6bc371d/cypy/__init__.py#L308-L322 |
cyrus-/cypy | cypy/__init__.py | remove_all | def remove_all(gset, elem):
"""Removes every occurrence of ``elem`` from ``gset``.
Returns the number of times ``elem`` was removed.
"""
n = 0
while True:
try:
remove_once(gset, elem)
n = n + 1
except RemoveError:
return n | python | def remove_all(gset, elem):
"""Removes every occurrence of ``elem`` from ``gset``.
Returns the number of times ``elem`` was removed.
"""
n = 0
while True:
try:
remove_once(gset, elem)
n = n + 1
except RemoveError:
return n | [
"def",
"remove_all",
"(",
"gset",
",",
"elem",
")",
":",
"n",
"=",
"0",
"while",
"True",
":",
"try",
":",
"remove_once",
"(",
"gset",
",",
"elem",
")",
"n",
"=",
"n",
"+",
"1",
"except",
"RemoveError",
":",
"return",
"n"
] | Removes every occurrence of ``elem`` from ``gset``.
Returns the number of times ``elem`` was removed. | [
"Removes",
"every",
"occurrence",
"of",
"elem",
"from",
"gset",
"."
] | train | https://github.com/cyrus-/cypy/blob/04bb59e91fa314e8cf987743189c77a9b6bc371d/cypy/__init__.py#L336-L347 |
cyrus-/cypy | cypy/__init__.py | is_iterable | def is_iterable(value, include_maps=False, include_sets=True):
"""Returns whether value is iterable.
``include_maps``
Maps are technically iterable, defaulting to their keys, but you
commonly want to find if it is a list-like type and leave maps alone,
so this is False by default.
... | python | def is_iterable(value, include_maps=False, include_sets=True):
"""Returns whether value is iterable.
``include_maps``
Maps are technically iterable, defaulting to their keys, but you
commonly want to find if it is a list-like type and leave maps alone,
so this is False by default.
... | [
"def",
"is_iterable",
"(",
"value",
",",
"include_maps",
"=",
"False",
",",
"include_sets",
"=",
"True",
")",
":",
"if",
"hasattr",
"(",
"value",
",",
"'__iter__'",
")",
":",
"if",
"not",
"include_maps",
"and",
"hasattr",
"(",
"value",
",",
"'keys'",
")"... | Returns whether value is iterable.
``include_maps``
Maps are technically iterable, defaulting to their keys, but you
commonly want to find if it is a list-like type and leave maps alone,
so this is False by default.
``include_sets``
Sets are also technically iterab... | [
"Returns",
"whether",
"value",
"is",
"iterable",
".",
"include_maps",
"Maps",
"are",
"technically",
"iterable",
"defaulting",
"to",
"their",
"keys",
"but",
"you",
"commonly",
"want",
"to",
"find",
"if",
"it",
"is",
"a",
"list",
"-",
"like",
"type",
"and",
... | train | https://github.com/cyrus-/cypy/blob/04bb59e91fa314e8cf987743189c77a9b6bc371d/cypy/__init__.py#L355-L379 |
cyrus-/cypy | cypy/__init__.py | as_iterable | def as_iterable(value, wrap_maps=True, wrap_sets=False, itertype=tuple):
"""Wraps a single non-iterable value with a tuple (or other iterable type,
if ``itertype`` is provided.)
>>> as_iterable("abc")
("abc",)
>>> as_iterable(("abc",))
("abc",)
Equivalent to::
... | python | def as_iterable(value, wrap_maps=True, wrap_sets=False, itertype=tuple):
"""Wraps a single non-iterable value with a tuple (or other iterable type,
if ``itertype`` is provided.)
>>> as_iterable("abc")
("abc",)
>>> as_iterable(("abc",))
("abc",)
Equivalent to::
... | [
"def",
"as_iterable",
"(",
"value",
",",
"wrap_maps",
"=",
"True",
",",
"wrap_sets",
"=",
"False",
",",
"itertype",
"=",
"tuple",
")",
":",
"if",
"is_iterable",
"(",
"value",
",",
"not",
"wrap_maps",
",",
"not",
"wrap_sets",
")",
":",
"return",
"value",
... | Wraps a single non-iterable value with a tuple (or other iterable type,
if ``itertype`` is provided.)
>>> as_iterable("abc")
("abc",)
>>> as_iterable(("abc",))
("abc",)
Equivalent to::
if is_iterable(value, not wrap_maps, not wrap_sets):
re... | [
"Wraps",
"a",
"single",
"non",
"-",
"iterable",
"value",
"with",
"a",
"tuple",
"(",
"or",
"other",
"iterable",
"type",
"if",
"itertype",
"is",
"provided",
".",
")",
">>>",
"as_iterable",
"(",
"abc",
")",
"(",
"abc",
")",
">>>",
"as_iterable",
"((",
"ab... | train | https://github.com/cyrus-/cypy/blob/04bb59e91fa314e8cf987743189c77a9b6bc371d/cypy/__init__.py#L381-L401 |
cyrus-/cypy | cypy/__init__.py | flatten | def flatten(iterable, check=is_iterable):
"""Produces a recursively flattened version of ``iterable``
``check``
Recurses only if check(value) is true.
"""
for value in iterable:
if check(value):
for flat in flatten(value, check):
yield flat
else:
... | python | def flatten(iterable, check=is_iterable):
"""Produces a recursively flattened version of ``iterable``
``check``
Recurses only if check(value) is true.
"""
for value in iterable:
if check(value):
for flat in flatten(value, check):
yield flat
else:
... | [
"def",
"flatten",
"(",
"iterable",
",",
"check",
"=",
"is_iterable",
")",
":",
"for",
"value",
"in",
"iterable",
":",
"if",
"check",
"(",
"value",
")",
":",
"for",
"flat",
"in",
"flatten",
"(",
"value",
",",
"check",
")",
":",
"yield",
"flat",
"else"... | Produces a recursively flattened version of ``iterable``
``check``
Recurses only if check(value) is true. | [
"Produces",
"a",
"recursively",
"flattened",
"version",
"of",
"iterable"
] | train | https://github.com/cyrus-/cypy/blob/04bb59e91fa314e8cf987743189c77a9b6bc371d/cypy/__init__.py#L423-L434 |
cyrus-/cypy | cypy/__init__.py | ed | def ed(fn, iterable, *args, **kwargs):
"""If ``fn`` maps ``iterable`` to a generator (e.g. :func:`flatten` and
others below), ``ed`` will consume the result and produce a tuple or list.
If ``iterable`` has a finite length (e.g. tuples, lists), uses the
same type to consume it. If not (e.g. generators),... | python | def ed(fn, iterable, *args, **kwargs):
"""If ``fn`` maps ``iterable`` to a generator (e.g. :func:`flatten` and
others below), ``ed`` will consume the result and produce a tuple or list.
If ``iterable`` has a finite length (e.g. tuples, lists), uses the
same type to consume it. If not (e.g. generators),... | [
"def",
"ed",
"(",
"fn",
",",
"iterable",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"hasattr",
"(",
"iterable",
",",
"'__len__'",
")",
":",
"return",
"iterable",
".",
"__class__",
"(",
"fn",
"(",
"iterable",
",",
"*",
"args",
",",
... | If ``fn`` maps ``iterable`` to a generator (e.g. :func:`flatten` and
others below), ``ed`` will consume the result and produce a tuple or list.
If ``iterable`` has a finite length (e.g. tuples, lists), uses the
same type to consume it. If not (e.g. generators), use a tuple.
The cypy functions have an ... | [
"If",
"fn",
"maps",
"iterable",
"to",
"a",
"generator",
"(",
"e",
".",
"g",
".",
":",
"func",
":",
"flatten",
"and",
"others",
"below",
")",
"ed",
"will",
"consume",
"the",
"result",
"and",
"produce",
"a",
"tuple",
"or",
"list",
"."
] | train | https://github.com/cyrus-/cypy/blob/04bb59e91fa314e8cf987743189c77a9b6bc371d/cypy/__init__.py#L436-L451 |
cyrus-/cypy | cypy/__init__.py | xflatten | def xflatten(iterable, transform, check=is_iterable):
"""Apply a transform to iterable before flattening at each level."""
for value in transform(iterable):
if check(value):
for flat in xflatten(value, transform, check):
yield flat
else:
yield value | python | def xflatten(iterable, transform, check=is_iterable):
"""Apply a transform to iterable before flattening at each level."""
for value in transform(iterable):
if check(value):
for flat in xflatten(value, transform, check):
yield flat
else:
yield value | [
"def",
"xflatten",
"(",
"iterable",
",",
"transform",
",",
"check",
"=",
"is_iterable",
")",
":",
"for",
"value",
"in",
"transform",
"(",
"iterable",
")",
":",
"if",
"check",
"(",
"value",
")",
":",
"for",
"flat",
"in",
"xflatten",
"(",
"value",
",",
... | Apply a transform to iterable before flattening at each level. | [
"Apply",
"a",
"transform",
"to",
"iterable",
"before",
"flattening",
"at",
"each",
"level",
"."
] | train | https://github.com/cyrus-/cypy/blob/04bb59e91fa314e8cf987743189c77a9b6bc371d/cypy/__init__.py#L469-L476 |
cyrus-/cypy | cypy/__init__.py | flatten_once | def flatten_once(iterable, check=is_iterable):
"""Flattens only the first level."""
for value in iterable:
if check(value):
for item in value:
yield item
else:
yield value | python | def flatten_once(iterable, check=is_iterable):
"""Flattens only the first level."""
for value in iterable:
if check(value):
for item in value:
yield item
else:
yield value | [
"def",
"flatten_once",
"(",
"iterable",
",",
"check",
"=",
"is_iterable",
")",
":",
"for",
"value",
"in",
"iterable",
":",
"if",
"check",
"(",
"value",
")",
":",
"for",
"item",
"in",
"value",
":",
"yield",
"item",
"else",
":",
"yield",
"value"
] | Flattens only the first level. | [
"Flattens",
"only",
"the",
"first",
"level",
"."
] | train | https://github.com/cyrus-/cypy/blob/04bb59e91fa314e8cf987743189c77a9b6bc371d/cypy/__init__.py#L480-L487 |
cyrus-/cypy | cypy/__init__.py | join | def join(iterable, sep):
"""Like str.join, but yields an iterable."""
i = 0
for i, item in enumerate(iterable):
if i == 0:
yield item
else:
yield sep
yield item | python | def join(iterable, sep):
"""Like str.join, but yields an iterable."""
i = 0
for i, item in enumerate(iterable):
if i == 0:
yield item
else:
yield sep
yield item | [
"def",
"join",
"(",
"iterable",
",",
"sep",
")",
":",
"i",
"=",
"0",
"for",
"i",
",",
"item",
"in",
"enumerate",
"(",
"iterable",
")",
":",
"if",
"i",
"==",
"0",
":",
"yield",
"item",
"else",
":",
"yield",
"sep",
"yield",
"item"
] | Like str.join, but yields an iterable. | [
"Like",
"str",
".",
"join",
"but",
"yields",
"an",
"iterable",
"."
] | train | https://github.com/cyrus-/cypy/blob/04bb59e91fa314e8cf987743189c77a9b6bc371d/cypy/__init__.py#L497-L505 |
cyrus-/cypy | cypy/__init__.py | stop_at | def stop_at(iterable, idx):
"""Stops iterating before yielding the specified idx."""
for i, item in enumerate(iterable):
if i == idx: return
yield item | python | def stop_at(iterable, idx):
"""Stops iterating before yielding the specified idx."""
for i, item in enumerate(iterable):
if i == idx: return
yield item | [
"def",
"stop_at",
"(",
"iterable",
",",
"idx",
")",
":",
"for",
"i",
",",
"item",
"in",
"enumerate",
"(",
"iterable",
")",
":",
"if",
"i",
"==",
"idx",
":",
"return",
"yield",
"item"
] | Stops iterating before yielding the specified idx. | [
"Stops",
"iterating",
"before",
"yielding",
"the",
"specified",
"idx",
"."
] | train | https://github.com/cyrus-/cypy/blob/04bb59e91fa314e8cf987743189c77a9b6bc371d/cypy/__init__.py#L508-L512 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.