partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test | Eaf.remove_license | Remove all licenses matching both key and value.
:param str name: Name of the license.
:param str url: URL of the license. | pympi/Elan.py | def remove_license(self, name=None, url=None):
"""Remove all licenses matching both key and value.
:param str name: Name of the license.
:param str url: URL of the license.
"""
for k, v in self.licenses[:]:
if (name is None or name == k) and (url is None or url == v)... | def remove_license(self, name=None, url=None):
"""Remove all licenses matching both key and value.
:param str name: Name of the license.
:param str url: URL of the license.
"""
for k, v in self.licenses[:]:
if (name is None or name == k) and (url is None or url == v)... | [
"Remove",
"all",
"licenses",
"matching",
"both",
"key",
"and",
"value",
"."
] | dopefishh/pympi | python | https://github.com/dopefishh/pympi/blob/79c747cde45b5ba203ed93154d8c123ac9c3ef56/pympi/Elan.py#L1144-L1152 | [
"def",
"remove_license",
"(",
"self",
",",
"name",
"=",
"None",
",",
"url",
"=",
"None",
")",
":",
"for",
"k",
",",
"v",
"in",
"self",
".",
"licenses",
"[",
":",
"]",
":",
"if",
"(",
"name",
"is",
"None",
"or",
"name",
"==",
"k",
")",
"and",
... | 79c747cde45b5ba203ed93154d8c123ac9c3ef56 |
test | Eaf.remove_linked_files | Remove all linked files that match all the criteria, criterias that
are ``None`` are ignored.
:param str file_path: Path of the file.
:param str relpath: Relative filepath.
:param str mimetype: Mimetype of the file.
:param int time_origin: Time origin.
:param str ex_from... | pympi/Elan.py | def remove_linked_files(self, file_path=None, relpath=None, mimetype=None,
time_origin=None, ex_from=None):
"""Remove all linked files that match all the criteria, criterias that
are ``None`` are ignored.
:param str file_path: Path of the file.
:param str rel... | def remove_linked_files(self, file_path=None, relpath=None, mimetype=None,
time_origin=None, ex_from=None):
"""Remove all linked files that match all the criteria, criterias that
are ``None`` are ignored.
:param str file_path: Path of the file.
:param str rel... | [
"Remove",
"all",
"linked",
"files",
"that",
"match",
"all",
"the",
"criteria",
"criterias",
"that",
"are",
"None",
"are",
"ignored",
"."
] | dopefishh/pympi | python | https://github.com/dopefishh/pympi/blob/79c747cde45b5ba203ed93154d8c123ac9c3ef56/pympi/Elan.py#L1162-L1185 | [
"def",
"remove_linked_files",
"(",
"self",
",",
"file_path",
"=",
"None",
",",
"relpath",
"=",
"None",
",",
"mimetype",
"=",
"None",
",",
"time_origin",
"=",
"None",
",",
"ex_from",
"=",
"None",
")",
":",
"for",
"attrib",
"in",
"self",
".",
"media_descri... | 79c747cde45b5ba203ed93154d8c123ac9c3ef56 |
test | Eaf.remove_property | Remove all properties matching both key and value.
:param str key: Key of the property.
:param str value: Value of the property. | pympi/Elan.py | def remove_property(self, key=None, value=None):
"""Remove all properties matching both key and value.
:param str key: Key of the property.
:param str value: Value of the property.
"""
for k, v in self.properties[:]:
if (key is None or key == k) and (value is None or... | def remove_property(self, key=None, value=None):
"""Remove all properties matching both key and value.
:param str key: Key of the property.
:param str value: Value of the property.
"""
for k, v in self.properties[:]:
if (key is None or key == k) and (value is None or... | [
"Remove",
"all",
"properties",
"matching",
"both",
"key",
"and",
"value",
"."
] | dopefishh/pympi | python | https://github.com/dopefishh/pympi/blob/79c747cde45b5ba203ed93154d8c123ac9c3ef56/pympi/Elan.py#L1195-L1203 | [
"def",
"remove_property",
"(",
"self",
",",
"key",
"=",
"None",
",",
"value",
"=",
"None",
")",
":",
"for",
"k",
",",
"v",
"in",
"self",
".",
"properties",
"[",
":",
"]",
":",
"if",
"(",
"key",
"is",
"None",
"or",
"key",
"==",
"k",
")",
"and",
... | 79c747cde45b5ba203ed93154d8c123ac9c3ef56 |
test | Eaf.remove_ref_annotation | Remove a reference annotation.
:param str id_tier: Name of tier.
:param int time: Time of the referenced annotation
:raises KeyError: If the tier is non existent.
:returns: Number of removed annotations. | pympi/Elan.py | def remove_ref_annotation(self, id_tier, time):
"""Remove a reference annotation.
:param str id_tier: Name of tier.
:param int time: Time of the referenced annotation
:raises KeyError: If the tier is non existent.
:returns: Number of removed annotations.
"""
remo... | def remove_ref_annotation(self, id_tier, time):
"""Remove a reference annotation.
:param str id_tier: Name of tier.
:param int time: Time of the referenced annotation
:raises KeyError: If the tier is non existent.
:returns: Number of removed annotations.
"""
remo... | [
"Remove",
"a",
"reference",
"annotation",
"."
] | dopefishh/pympi | python | https://github.com/dopefishh/pympi/blob/79c747cde45b5ba203ed93154d8c123ac9c3ef56/pympi/Elan.py#L1205-L1224 | [
"def",
"remove_ref_annotation",
"(",
"self",
",",
"id_tier",
",",
"time",
")",
":",
"removed",
"=",
"0",
"bucket",
"=",
"[",
"]",
"for",
"aid",
",",
"(",
"ref",
",",
"value",
",",
"_",
",",
"_",
")",
"in",
"self",
".",
"tiers",
"[",
"id_tier",
"]... | 79c747cde45b5ba203ed93154d8c123ac9c3ef56 |
test | Eaf.remove_secondary_linked_files | Remove all secondary linked files that match all the criteria,
criterias that are ``None`` are ignored.
:param str file_path: Path of the file.
:param str relpath: Relative filepath.
:param str mimetype: Mimetype of the file.
:param int time_origin: Time origin.
:param s... | pympi/Elan.py | def remove_secondary_linked_files(self, file_path=None, relpath=None,
mimetype=None, time_origin=None,
assoc_with=None):
"""Remove all secondary linked files that match all the criteria,
criterias that are ``None`` are ignored.
... | def remove_secondary_linked_files(self, file_path=None, relpath=None,
mimetype=None, time_origin=None,
assoc_with=None):
"""Remove all secondary linked files that match all the criteria,
criterias that are ``None`` are ignored.
... | [
"Remove",
"all",
"secondary",
"linked",
"files",
"that",
"match",
"all",
"the",
"criteria",
"criterias",
"that",
"are",
"None",
"are",
"ignored",
"."
] | dopefishh/pympi | python | https://github.com/dopefishh/pympi/blob/79c747cde45b5ba203ed93154d8c123ac9c3ef56/pympi/Elan.py#L1226-L1252 | [
"def",
"remove_secondary_linked_files",
"(",
"self",
",",
"file_path",
"=",
"None",
",",
"relpath",
"=",
"None",
",",
"mimetype",
"=",
"None",
",",
"time_origin",
"=",
"None",
",",
"assoc_with",
"=",
"None",
")",
":",
"for",
"attrib",
"in",
"self",
".",
... | 79c747cde45b5ba203ed93154d8c123ac9c3ef56 |
test | Eaf.remove_tier | Remove a tier.
:param str id_tier: Name of the tier.
:param bool clean: Flag to also clean the timeslots.
:raises KeyError: If tier is non existent. | pympi/Elan.py | def remove_tier(self, id_tier, clean=True):
"""Remove a tier.
:param str id_tier: Name of the tier.
:param bool clean: Flag to also clean the timeslots.
:raises KeyError: If tier is non existent.
"""
del(self.tiers[id_tier])
if clean:
self.clean_time_... | def remove_tier(self, id_tier, clean=True):
"""Remove a tier.
:param str id_tier: Name of the tier.
:param bool clean: Flag to also clean the timeslots.
:raises KeyError: If tier is non existent.
"""
del(self.tiers[id_tier])
if clean:
self.clean_time_... | [
"Remove",
"a",
"tier",
"."
] | dopefishh/pympi | python | https://github.com/dopefishh/pympi/blob/79c747cde45b5ba203ed93154d8c123ac9c3ef56/pympi/Elan.py#L1254-L1263 | [
"def",
"remove_tier",
"(",
"self",
",",
"id_tier",
",",
"clean",
"=",
"True",
")",
":",
"del",
"(",
"self",
".",
"tiers",
"[",
"id_tier",
"]",
")",
"if",
"clean",
":",
"self",
".",
"clean_time_slots",
"(",
")"
] | 79c747cde45b5ba203ed93154d8c123ac9c3ef56 |
test | Eaf.remove_tiers | Remove multiple tiers, note that this is a lot faster then removing
them individually because of the delayed cleaning of timeslots.
:param list tiers: Names of the tier to remove.
:raises KeyError: If a tier is non existent. | pympi/Elan.py | def remove_tiers(self, tiers):
"""Remove multiple tiers, note that this is a lot faster then removing
them individually because of the delayed cleaning of timeslots.
:param list tiers: Names of the tier to remove.
:raises KeyError: If a tier is non existent.
"""
for a in... | def remove_tiers(self, tiers):
"""Remove multiple tiers, note that this is a lot faster then removing
them individually because of the delayed cleaning of timeslots.
:param list tiers: Names of the tier to remove.
:raises KeyError: If a tier is non existent.
"""
for a in... | [
"Remove",
"multiple",
"tiers",
"note",
"that",
"this",
"is",
"a",
"lot",
"faster",
"then",
"removing",
"them",
"individually",
"because",
"of",
"the",
"delayed",
"cleaning",
"of",
"timeslots",
"."
] | dopefishh/pympi | python | https://github.com/dopefishh/pympi/blob/79c747cde45b5ba203ed93154d8c123ac9c3ef56/pympi/Elan.py#L1265-L1274 | [
"def",
"remove_tiers",
"(",
"self",
",",
"tiers",
")",
":",
"for",
"a",
"in",
"tiers",
":",
"self",
".",
"remove_tier",
"(",
"a",
",",
"clean",
"=",
"False",
")",
"self",
".",
"clean_time_slots",
"(",
")"
] | 79c747cde45b5ba203ed93154d8c123ac9c3ef56 |
test | Eaf.rename_tier | Rename a tier. Note that this renames also the child tiers that have
the tier as a parent.
:param str id_from: Original name of the tier.
:param str id_to: Target name of the tier.
:throws KeyError: If the tier doesnt' exist. | pympi/Elan.py | def rename_tier(self, id_from, id_to):
"""Rename a tier. Note that this renames also the child tiers that have
the tier as a parent.
:param str id_from: Original name of the tier.
:param str id_to: Target name of the tier.
:throws KeyError: If the tier doesnt' exist.
"""... | def rename_tier(self, id_from, id_to):
"""Rename a tier. Note that this renames also the child tiers that have
the tier as a parent.
:param str id_from: Original name of the tier.
:param str id_to: Target name of the tier.
:throws KeyError: If the tier doesnt' exist.
"""... | [
"Rename",
"a",
"tier",
".",
"Note",
"that",
"this",
"renames",
"also",
"the",
"child",
"tiers",
"that",
"have",
"the",
"tier",
"as",
"a",
"parent",
"."
] | dopefishh/pympi | python | https://github.com/dopefishh/pympi/blob/79c747cde45b5ba203ed93154d8c123ac9c3ef56/pympi/Elan.py#L1276-L1288 | [
"def",
"rename_tier",
"(",
"self",
",",
"id_from",
",",
"id_to",
")",
":",
"childs",
"=",
"self",
".",
"get_child_tiers_for",
"(",
"id_from",
")",
"self",
".",
"tiers",
"[",
"id_to",
"]",
"=",
"self",
".",
"tiers",
".",
"pop",
"(",
"id_from",
")",
"s... | 79c747cde45b5ba203ed93154d8c123ac9c3ef56 |
test | Eaf.shift_annotations | Shift all annotations in time. Annotations that are in the beginning
and a left shift is applied can be squashed or discarded.
:param int time: Time shift width, negative numbers make a left shift.
:returns: Tuple of a list of squashed annotations and a list of removed
annotat... | pympi/Elan.py | def shift_annotations(self, time):
"""Shift all annotations in time. Annotations that are in the beginning
and a left shift is applied can be squashed or discarded.
:param int time: Time shift width, negative numbers make a left shift.
:returns: Tuple of a list of squashed annotations a... | def shift_annotations(self, time):
"""Shift all annotations in time. Annotations that are in the beginning
and a left shift is applied can be squashed or discarded.
:param int time: Time shift width, negative numbers make a left shift.
:returns: Tuple of a list of squashed annotations a... | [
"Shift",
"all",
"annotations",
"in",
"time",
".",
"Annotations",
"that",
"are",
"in",
"the",
"beginning",
"and",
"a",
"left",
"shift",
"is",
"applied",
"can",
"be",
"squashed",
"or",
"discarded",
"."
] | dopefishh/pympi | python | https://github.com/dopefishh/pympi/blob/79c747cde45b5ba203ed93154d8c123ac9c3ef56/pympi/Elan.py#L1290-L1318 | [
"def",
"shift_annotations",
"(",
"self",
",",
"time",
")",
":",
"total_re",
"=",
"[",
"]",
"total_sq",
"=",
"[",
"]",
"for",
"name",
",",
"tier",
"in",
"self",
".",
"tiers",
".",
"items",
"(",
")",
":",
"squashed",
"=",
"[",
"]",
"for",
"aid",
",... | 79c747cde45b5ba203ed93154d8c123ac9c3ef56 |
test | Eaf.to_textgrid | Convert the object to a :class:`pympi.Praat.TextGrid` object.
:param list filtin: Include only tiers in this list, if empty
all tiers are included.
:param list filtex: Exclude all tiers in this list.
:param bool regex: If this flag is set the filters are seen as regexes.
:re... | pympi/Elan.py | def to_textgrid(self, filtin=[], filtex=[], regex=False):
"""Convert the object to a :class:`pympi.Praat.TextGrid` object.
:param list filtin: Include only tiers in this list, if empty
all tiers are included.
:param list filtex: Exclude all tiers in this list.
:param bool re... | def to_textgrid(self, filtin=[], filtex=[], regex=False):
"""Convert the object to a :class:`pympi.Praat.TextGrid` object.
:param list filtin: Include only tiers in this list, if empty
all tiers are included.
:param list filtex: Exclude all tiers in this list.
:param bool re... | [
"Convert",
"the",
"object",
"to",
"a",
":",
"class",
":",
"pympi",
".",
"Praat",
".",
"TextGrid",
"object",
"."
] | dopefishh/pympi | python | https://github.com/dopefishh/pympi/blob/79c747cde45b5ba203ed93154d8c123ac9c3ef56/pympi/Elan.py#L1331-L1355 | [
"def",
"to_textgrid",
"(",
"self",
",",
"filtin",
"=",
"[",
"]",
",",
"filtex",
"=",
"[",
"]",
",",
"regex",
"=",
"False",
")",
":",
"from",
"pympi",
".",
"Praat",
"import",
"TextGrid",
"_",
",",
"end",
"=",
"self",
".",
"get_full_time_interval",
"("... | 79c747cde45b5ba203ed93154d8c123ac9c3ef56 |
test | main | Will be used to create the console script | bidi/__init__.py | def main():
"""Will be used to create the console script"""
import optparse
import sys
import codecs
import locale
import six
from .algorithm import get_display
parser = optparse.OptionParser()
parser.add_option('-e', '--encoding',
dest='encoding',
... | def main():
"""Will be used to create the console script"""
import optparse
import sys
import codecs
import locale
import six
from .algorithm import get_display
parser = optparse.OptionParser()
parser.add_option('-e', '--encoding',
dest='encoding',
... | [
"Will",
"be",
"used",
"to",
"create",
"the",
"console",
"script"
] | MeirKriheli/python-bidi | python | https://github.com/MeirKriheli/python-bidi/blob/a0e265bb465c1b7ad628487991e33b5ebe364641/bidi/__init__.py#L28-L86 | [
"def",
"main",
"(",
")",
":",
"import",
"optparse",
"import",
"sys",
"import",
"codecs",
"import",
"locale",
"import",
"six",
"from",
".",
"algorithm",
"import",
"get_display",
"parser",
"=",
"optparse",
".",
"OptionParser",
"(",
")",
"parser",
".",
"add_opt... | a0e265bb465c1b7ad628487991e33b5ebe364641 |
test | debug_storage | Display debug information for the storage | bidi/algorithm.py | def debug_storage(storage, base_info=False, chars=True, runs=False):
"Display debug information for the storage"
import codecs
import locale
import sys
if six.PY2:
stderr = codecs.getwriter(locale.getpreferredencoding())(sys.stderr)
else:
stderr = sys.stderr
caller = inspe... | def debug_storage(storage, base_info=False, chars=True, runs=False):
"Display debug information for the storage"
import codecs
import locale
import sys
if six.PY2:
stderr = codecs.getwriter(locale.getpreferredencoding())(sys.stderr)
else:
stderr = sys.stderr
caller = inspe... | [
"Display",
"debug",
"information",
"for",
"the",
"storage"
] | MeirKriheli/python-bidi | python | https://github.com/MeirKriheli/python-bidi/blob/a0e265bb465c1b7ad628487991e33b5ebe364641/bidi/algorithm.py#L62-L104 | [
"def",
"debug_storage",
"(",
"storage",
",",
"base_info",
"=",
"False",
",",
"chars",
"=",
"True",
",",
"runs",
"=",
"False",
")",
":",
"import",
"codecs",
"import",
"locale",
"import",
"sys",
"if",
"six",
".",
"PY2",
":",
"stderr",
"=",
"codecs",
".",... | a0e265bb465c1b7ad628487991e33b5ebe364641 |
test | get_base_level | Get the paragraph base embedding level. Returns 0 for LTR,
1 for RTL.
`text` a unicode object.
Set `upper_is_rtl` to True to treat upper case chars as strong 'R'
for debugging (default: False). | bidi/algorithm.py | def get_base_level(text, upper_is_rtl=False):
"""Get the paragraph base embedding level. Returns 0 for LTR,
1 for RTL.
`text` a unicode object.
Set `upper_is_rtl` to True to treat upper case chars as strong 'R'
for debugging (default: False).
"""
base_level = None
prev_surrogate = F... | def get_base_level(text, upper_is_rtl=False):
"""Get the paragraph base embedding level. Returns 0 for LTR,
1 for RTL.
`text` a unicode object.
Set `upper_is_rtl` to True to treat upper case chars as strong 'R'
for debugging (default: False).
"""
base_level = None
prev_surrogate = F... | [
"Get",
"the",
"paragraph",
"base",
"embedding",
"level",
".",
"Returns",
"0",
"for",
"LTR",
"1",
"for",
"RTL",
"."
] | MeirKriheli/python-bidi | python | https://github.com/MeirKriheli/python-bidi/blob/a0e265bb465c1b7ad628487991e33b5ebe364641/bidi/algorithm.py#L107-L150 | [
"def",
"get_base_level",
"(",
"text",
",",
"upper_is_rtl",
"=",
"False",
")",
":",
"base_level",
"=",
"None",
"prev_surrogate",
"=",
"False",
"# P2",
"for",
"_ch",
"in",
"text",
":",
"# surrogate in case of ucs2",
"if",
"_IS_UCS2",
"and",
"(",
"_SURROGATE_MIN",
... | a0e265bb465c1b7ad628487991e33b5ebe364641 |
test | get_embedding_levels | Get the paragraph base embedding level and direction,
set the storage to the array of chars | bidi/algorithm.py | def get_embedding_levels(text, storage, upper_is_rtl=False, debug=False):
"""Get the paragraph base embedding level and direction,
set the storage to the array of chars"""
prev_surrogate = False
base_level = storage['base_level']
# preset the storage's chars
for _ch in text:
if _IS_UCS... | def get_embedding_levels(text, storage, upper_is_rtl=False, debug=False):
"""Get the paragraph base embedding level and direction,
set the storage to the array of chars"""
prev_surrogate = False
base_level = storage['base_level']
# preset the storage's chars
for _ch in text:
if _IS_UCS... | [
"Get",
"the",
"paragraph",
"base",
"embedding",
"level",
"and",
"direction",
"set",
"the",
"storage",
"to",
"the",
"array",
"of",
"chars"
] | MeirKriheli/python-bidi | python | https://github.com/MeirKriheli/python-bidi/blob/a0e265bb465c1b7ad628487991e33b5ebe364641/bidi/algorithm.py#L153-L181 | [
"def",
"get_embedding_levels",
"(",
"text",
",",
"storage",
",",
"upper_is_rtl",
"=",
"False",
",",
"debug",
"=",
"False",
")",
":",
"prev_surrogate",
"=",
"False",
"base_level",
"=",
"storage",
"[",
"'base_level'",
"]",
"# preset the storage's chars",
"for",
"_... | a0e265bb465c1b7ad628487991e33b5ebe364641 |
test | explicit_embed_and_overrides | Apply X1 to X9 rules of the unicode algorithm.
See http://unicode.org/reports/tr9/#Explicit_Levels_and_Directions | bidi/algorithm.py | def explicit_embed_and_overrides(storage, debug=False):
"""Apply X1 to X9 rules of the unicode algorithm.
See http://unicode.org/reports/tr9/#Explicit_Levels_and_Directions
"""
overflow_counter = almost_overflow_counter = 0
directional_override = 'N'
levels = deque()
# X1
embedding_le... | def explicit_embed_and_overrides(storage, debug=False):
"""Apply X1 to X9 rules of the unicode algorithm.
See http://unicode.org/reports/tr9/#Explicit_Levels_and_Directions
"""
overflow_counter = almost_overflow_counter = 0
directional_override = 'N'
levels = deque()
# X1
embedding_le... | [
"Apply",
"X1",
"to",
"X9",
"rules",
"of",
"the",
"unicode",
"algorithm",
"."
] | MeirKriheli/python-bidi | python | https://github.com/MeirKriheli/python-bidi/blob/a0e265bb465c1b7ad628487991e33b5ebe364641/bidi/algorithm.py#L184-L258 | [
"def",
"explicit_embed_and_overrides",
"(",
"storage",
",",
"debug",
"=",
"False",
")",
":",
"overflow_counter",
"=",
"almost_overflow_counter",
"=",
"0",
"directional_override",
"=",
"'N'",
"levels",
"=",
"deque",
"(",
")",
"# X1",
"embedding_level",
"=",
"storag... | a0e265bb465c1b7ad628487991e33b5ebe364641 |
test | calc_level_runs | Split the storage to run of char types at the same level.
Applies X10. See http://unicode.org/reports/tr9/#X10 | bidi/algorithm.py | def calc_level_runs(storage):
"""Split the storage to run of char types at the same level.
Applies X10. See http://unicode.org/reports/tr9/#X10
"""
# run level depends on the higher of the two levels on either side of
# the boundary If the higher level is odd, the type is R; otherwise,
# it is ... | def calc_level_runs(storage):
"""Split the storage to run of char types at the same level.
Applies X10. See http://unicode.org/reports/tr9/#X10
"""
# run level depends on the higher of the two levels on either side of
# the boundary If the higher level is odd, the type is R; otherwise,
# it is ... | [
"Split",
"the",
"storage",
"to",
"run",
"of",
"char",
"types",
"at",
"the",
"same",
"level",
"."
] | MeirKriheli/python-bidi | python | https://github.com/MeirKriheli/python-bidi/blob/a0e265bb465c1b7ad628487991e33b5ebe364641/bidi/algorithm.py#L261-L307 | [
"def",
"calc_level_runs",
"(",
"storage",
")",
":",
"# run level depends on the higher of the two levels on either side of",
"# the boundary If the higher level is odd, the type is R; otherwise,",
"# it is L",
"storage",
"[",
"'runs'",
"]",
".",
"clear",
"(",
")",
"chars",
"=",
... | a0e265bb465c1b7ad628487991e33b5ebe364641 |
test | resolve_weak_types | Reslove weak type rules W1 - W3.
See: http://unicode.org/reports/tr9/#Resolving_Weak_Types | bidi/algorithm.py | def resolve_weak_types(storage, debug=False):
"""Reslove weak type rules W1 - W3.
See: http://unicode.org/reports/tr9/#Resolving_Weak_Types
"""
for run in storage['runs']:
prev_strong = prev_type = run['sor']
start, length = run['start'], run['length']
chars = storage['chars']... | def resolve_weak_types(storage, debug=False):
"""Reslove weak type rules W1 - W3.
See: http://unicode.org/reports/tr9/#Resolving_Weak_Types
"""
for run in storage['runs']:
prev_strong = prev_type = run['sor']
start, length = run['start'], run['length']
chars = storage['chars']... | [
"Reslove",
"weak",
"type",
"rules",
"W1",
"-",
"W3",
"."
] | MeirKriheli/python-bidi | python | https://github.com/MeirKriheli/python-bidi/blob/a0e265bb465c1b7ad628487991e33b5ebe364641/bidi/algorithm.py#L310-L395 | [
"def",
"resolve_weak_types",
"(",
"storage",
",",
"debug",
"=",
"False",
")",
":",
"for",
"run",
"in",
"storage",
"[",
"'runs'",
"]",
":",
"prev_strong",
"=",
"prev_type",
"=",
"run",
"[",
"'sor'",
"]",
"start",
",",
"length",
"=",
"run",
"[",
"'start'... | a0e265bb465c1b7ad628487991e33b5ebe364641 |
test | resolve_neutral_types | Resolving neutral types. Implements N1 and N2
See: http://unicode.org/reports/tr9/#Resolving_Neutral_Types | bidi/algorithm.py | def resolve_neutral_types(storage, debug):
"""Resolving neutral types. Implements N1 and N2
See: http://unicode.org/reports/tr9/#Resolving_Neutral_Types
"""
for run in storage['runs']:
start, length = run['start'], run['length']
# use sor and eor
chars = [{'type': run['sor']}]... | def resolve_neutral_types(storage, debug):
"""Resolving neutral types. Implements N1 and N2
See: http://unicode.org/reports/tr9/#Resolving_Neutral_Types
"""
for run in storage['runs']:
start, length = run['start'], run['length']
# use sor and eor
chars = [{'type': run['sor']}]... | [
"Resolving",
"neutral",
"types",
".",
"Implements",
"N1",
"and",
"N2"
] | MeirKriheli/python-bidi | python | https://github.com/MeirKriheli/python-bidi/blob/a0e265bb465c1b7ad628487991e33b5ebe364641/bidi/algorithm.py#L398-L450 | [
"def",
"resolve_neutral_types",
"(",
"storage",
",",
"debug",
")",
":",
"for",
"run",
"in",
"storage",
"[",
"'runs'",
"]",
":",
"start",
",",
"length",
"=",
"run",
"[",
"'start'",
"]",
",",
"run",
"[",
"'length'",
"]",
"# use sor and eor",
"chars",
"=",
... | a0e265bb465c1b7ad628487991e33b5ebe364641 |
test | resolve_implicit_levels | Resolving implicit levels (I1, I2)
See: http://unicode.org/reports/tr9/#Resolving_Implicit_Levels | bidi/algorithm.py | def resolve_implicit_levels(storage, debug):
"""Resolving implicit levels (I1, I2)
See: http://unicode.org/reports/tr9/#Resolving_Implicit_Levels
"""
for run in storage['runs']:
start, length = run['start'], run['length']
chars = storage['chars'][start:start+length]
for _ch in... | def resolve_implicit_levels(storage, debug):
"""Resolving implicit levels (I1, I2)
See: http://unicode.org/reports/tr9/#Resolving_Implicit_Levels
"""
for run in storage['runs']:
start, length = run['start'], run['length']
chars = storage['chars'][start:start+length]
for _ch in... | [
"Resolving",
"implicit",
"levels",
"(",
"I1",
"I2",
")"
] | MeirKriheli/python-bidi | python | https://github.com/MeirKriheli/python-bidi/blob/a0e265bb465c1b7ad628487991e33b5ebe364641/bidi/algorithm.py#L453-L483 | [
"def",
"resolve_implicit_levels",
"(",
"storage",
",",
"debug",
")",
":",
"for",
"run",
"in",
"storage",
"[",
"'runs'",
"]",
":",
"start",
",",
"length",
"=",
"run",
"[",
"'start'",
"]",
",",
"run",
"[",
"'length'",
"]",
"chars",
"=",
"storage",
"[",
... | a0e265bb465c1b7ad628487991e33b5ebe364641 |
test | reverse_contiguous_sequence | L2. From the highest level found in the text to the lowest odd
level on each line, including intermediate levels not actually
present in the text, reverse any contiguous sequence of characters
that are at that level or higher. | bidi/algorithm.py | def reverse_contiguous_sequence(chars, line_start, line_end, highest_level,
lowest_odd_level):
"""L2. From the highest level found in the text to the lowest odd
level on each line, including intermediate levels not actually
present in the text, reverse any contiguous sequence... | def reverse_contiguous_sequence(chars, line_start, line_end, highest_level,
lowest_odd_level):
"""L2. From the highest level found in the text to the lowest odd
level on each line, including intermediate levels not actually
present in the text, reverse any contiguous sequence... | [
"L2",
".",
"From",
"the",
"highest",
"level",
"found",
"in",
"the",
"text",
"to",
"the",
"lowest",
"odd",
"level",
"on",
"each",
"line",
"including",
"intermediate",
"levels",
"not",
"actually",
"present",
"in",
"the",
"text",
"reverse",
"any",
"contiguous",... | MeirKriheli/python-bidi | python | https://github.com/MeirKriheli/python-bidi/blob/a0e265bb465c1b7ad628487991e33b5ebe364641/bidi/algorithm.py#L486-L514 | [
"def",
"reverse_contiguous_sequence",
"(",
"chars",
",",
"line_start",
",",
"line_end",
",",
"highest_level",
",",
"lowest_odd_level",
")",
":",
"for",
"level",
"in",
"range",
"(",
"highest_level",
",",
"lowest_odd_level",
"-",
"1",
",",
"-",
"1",
")",
":",
... | a0e265bb465c1b7ad628487991e33b5ebe364641 |
test | reorder_resolved_levels | L1 and L2 rules | bidi/algorithm.py | def reorder_resolved_levels(storage, debug):
"""L1 and L2 rules"""
# Applies L1.
should_reset = True
chars = storage['chars']
for _ch in chars[::-1]:
# L1. On each line, reset the embedding level of the following
# characters to the paragraph embedding level:
if _ch['orig'... | def reorder_resolved_levels(storage, debug):
"""L1 and L2 rules"""
# Applies L1.
should_reset = True
chars = storage['chars']
for _ch in chars[::-1]:
# L1. On each line, reset the embedding level of the following
# characters to the paragraph embedding level:
if _ch['orig'... | [
"L1",
"and",
"L2",
"rules"
] | MeirKriheli/python-bidi | python | https://github.com/MeirKriheli/python-bidi/blob/a0e265bb465c1b7ad628487991e33b5ebe364641/bidi/algorithm.py#L517-L577 | [
"def",
"reorder_resolved_levels",
"(",
"storage",
",",
"debug",
")",
":",
"# Applies L1.",
"should_reset",
"=",
"True",
"chars",
"=",
"storage",
"[",
"'chars'",
"]",
"for",
"_ch",
"in",
"chars",
"[",
":",
":",
"-",
"1",
"]",
":",
"# L1. On each line, reset t... | a0e265bb465c1b7ad628487991e33b5ebe364641 |
test | apply_mirroring | Applies L4: mirroring
See: http://unicode.org/reports/tr9/#L4 | bidi/algorithm.py | def apply_mirroring(storage, debug):
"""Applies L4: mirroring
See: http://unicode.org/reports/tr9/#L4
"""
# L4. A character is depicted by a mirrored glyph if and only if (a) the
# resolved directionality of that character is R, and (b) the
# Bidi_Mirrored property value of that character is t... | def apply_mirroring(storage, debug):
"""Applies L4: mirroring
See: http://unicode.org/reports/tr9/#L4
"""
# L4. A character is depicted by a mirrored glyph if and only if (a) the
# resolved directionality of that character is R, and (b) the
# Bidi_Mirrored property value of that character is t... | [
"Applies",
"L4",
":",
"mirroring"
] | MeirKriheli/python-bidi | python | https://github.com/MeirKriheli/python-bidi/blob/a0e265bb465c1b7ad628487991e33b5ebe364641/bidi/algorithm.py#L580-L596 | [
"def",
"apply_mirroring",
"(",
"storage",
",",
"debug",
")",
":",
"# L4. A character is depicted by a mirrored glyph if and only if (a) the",
"# resolved directionality of that character is R, and (b) the",
"# Bidi_Mirrored property value of that character is true.",
"for",
"_ch",
"in",
... | a0e265bb465c1b7ad628487991e33b5ebe364641 |
test | get_display | Accepts unicode or string. In case it's a string, `encoding`
is needed as it works on unicode ones (default:"utf-8").
Set `upper_is_rtl` to True to treat upper case chars as strong 'R'
for debugging (default: False).
Set `base_dir` to 'L' or 'R' to override the calculated base_level.
Set `debug` ... | bidi/algorithm.py | def get_display(unicode_or_str, encoding='utf-8', upper_is_rtl=False,
base_dir=None, debug=False):
"""Accepts unicode or string. In case it's a string, `encoding`
is needed as it works on unicode ones (default:"utf-8").
Set `upper_is_rtl` to True to treat upper case chars as strong 'R'
... | def get_display(unicode_or_str, encoding='utf-8', upper_is_rtl=False,
base_dir=None, debug=False):
"""Accepts unicode or string. In case it's a string, `encoding`
is needed as it works on unicode ones (default:"utf-8").
Set `upper_is_rtl` to True to treat upper case chars as strong 'R'
... | [
"Accepts",
"unicode",
"or",
"string",
".",
"In",
"case",
"it",
"s",
"a",
"string",
"encoding",
"is",
"needed",
"as",
"it",
"works",
"on",
"unicode",
"ones",
"(",
"default",
":",
"utf",
"-",
"8",
")",
"."
] | MeirKriheli/python-bidi | python | https://github.com/MeirKriheli/python-bidi/blob/a0e265bb465c1b7ad628487991e33b5ebe364641/bidi/algorithm.py#L609-L658 | [
"def",
"get_display",
"(",
"unicode_or_str",
",",
"encoding",
"=",
"'utf-8'",
",",
"upper_is_rtl",
"=",
"False",
",",
"base_dir",
"=",
"None",
",",
"debug",
"=",
"False",
")",
":",
"storage",
"=",
"get_empty_storage",
"(",
")",
"# utf-8 ? we need unicode",
"if... | a0e265bb465c1b7ad628487991e33b5ebe364641 |
test | CollectMayaCurrentFile.process | Inject the current working file | pyblish_maya/plugins/collect_current_file.py | def process(self, context):
import os
from maya import cmds
"""Inject the current working file"""
current_file = cmds.file(sceneName=True, query=True)
# Maya returns forward-slashes by default
normalised = os.path.normpath(current_file)
context.set_data('curren... | def process(self, context):
import os
from maya import cmds
"""Inject the current working file"""
current_file = cmds.file(sceneName=True, query=True)
# Maya returns forward-slashes by default
normalised = os.path.normpath(current_file)
context.set_data('curren... | [
"Inject",
"the",
"current",
"working",
"file"
] | pyblish/pyblish-maya | python | https://github.com/pyblish/pyblish-maya/blob/75db8b5d8de9d53ae95e74195a788b5f6db2cb5f/pyblish_maya/plugins/collect_current_file.py#L13-L26 | [
"def",
"process",
"(",
"self",
",",
"context",
")",
":",
"import",
"os",
"from",
"maya",
"import",
"cmds",
"current_file",
"=",
"cmds",
".",
"file",
"(",
"sceneName",
"=",
"True",
",",
"query",
"=",
"True",
")",
"# Maya returns forward-slashes by default",
"... | 75db8b5d8de9d53ae95e74195a788b5f6db2cb5f |
test | convert | Convert compiled .ui file from PySide2 to Qt.py
Arguments:
lines (list): Each line of of .ui file
Usage:
>> with open("myui.py") as f:
.. lines = convert(f.readlines()) | pyblish_maya/vendor/Qt.py | def convert(lines):
"""Convert compiled .ui file from PySide2 to Qt.py
Arguments:
lines (list): Each line of of .ui file
Usage:
>> with open("myui.py") as f:
.. lines = convert(f.readlines())
"""
def parse(line):
line = line.replace("from PySide2 import", "from ... | def convert(lines):
"""Convert compiled .ui file from PySide2 to Qt.py
Arguments:
lines (list): Each line of of .ui file
Usage:
>> with open("myui.py") as f:
.. lines = convert(f.readlines())
"""
def parse(line):
line = line.replace("from PySide2 import", "from ... | [
"Convert",
"compiled",
".",
"ui",
"file",
"from",
"PySide2",
"to",
"Qt",
".",
"py"
] | pyblish/pyblish-maya | python | https://github.com/pyblish/pyblish-maya/blob/75db8b5d8de9d53ae95e74195a788b5f6db2cb5f/pyblish_maya/vendor/Qt.py#L87-L110 | [
"def",
"convert",
"(",
"lines",
")",
":",
"def",
"parse",
"(",
"line",
")",
":",
"line",
"=",
"line",
".",
"replace",
"(",
"\"from PySide2 import\"",
",",
"\"from Qt import\"",
")",
"line",
"=",
"line",
".",
"replace",
"(",
"\"QtWidgets.QApplication.translate\... | 75db8b5d8de9d53ae95e74195a788b5f6db2cb5f |
test | _add | Append to self, accessible via Qt.QtCompat | pyblish_maya/vendor/Qt.py | def _add(object, name, value):
"""Append to self, accessible via Qt.QtCompat"""
self.__added__.append(name)
setattr(object, name, value) | def _add(object, name, value):
"""Append to self, accessible via Qt.QtCompat"""
self.__added__.append(name)
setattr(object, name, value) | [
"Append",
"to",
"self",
"accessible",
"via",
"Qt",
".",
"QtCompat"
] | pyblish/pyblish-maya | python | https://github.com/pyblish/pyblish-maya/blob/75db8b5d8de9d53ae95e74195a788b5f6db2cb5f/pyblish_maya/vendor/Qt.py#L147-L150 | [
"def",
"_add",
"(",
"object",
",",
"name",
",",
"value",
")",
":",
"self",
".",
"__added__",
".",
"append",
"(",
"name",
")",
"setattr",
"(",
"object",
",",
"name",
",",
"value",
")"
] | 75db8b5d8de9d53ae95e74195a788b5f6db2cb5f |
test | cli | Qt.py command-line interface | pyblish_maya/vendor/Qt.py | def cli(args):
"""Qt.py command-line interface"""
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--convert",
help="Path to compiled Python module, e.g. my_ui.py")
parser.add_argument("--compile",
help="Accept raw .ui file and ... | def cli(args):
"""Qt.py command-line interface"""
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--convert",
help="Path to compiled Python module, e.g. my_ui.py")
parser.add_argument("--compile",
help="Accept raw .ui file and ... | [
"Qt",
".",
"py",
"command",
"-",
"line",
"interface"
] | pyblish/pyblish-maya | python | https://github.com/pyblish/pyblish-maya/blob/75db8b5d8de9d53ae95e74195a788b5f6db2cb5f/pyblish_maya/vendor/Qt.py#L297-L348 | [
"def",
"cli",
"(",
"args",
")",
":",
"import",
"argparse",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"\"--convert\"",
",",
"help",
"=",
"\"Path to compiled Python module, e.g. my_ui.py\"",
")",
"parser",
".",
... | 75db8b5d8de9d53ae95e74195a788b5f6db2cb5f |
test | _maintain_backwards_compatibility | Add members found in prior versions up till the next major release
These members are to be considered deprecated. When a new major
release is made, these members are removed. | pyblish_maya/vendor/Qt.py | def _maintain_backwards_compatibility(binding):
"""Add members found in prior versions up till the next major release
These members are to be considered deprecated. When a new major
release is made, these members are removed.
"""
for member in ("__binding__",
"__binding_version... | def _maintain_backwards_compatibility(binding):
"""Add members found in prior versions up till the next major release
These members are to be considered deprecated. When a new major
release is made, these members are removed.
"""
for member in ("__binding__",
"__binding_version... | [
"Add",
"members",
"found",
"in",
"prior",
"versions",
"up",
"till",
"the",
"next",
"major",
"release"
] | pyblish/pyblish-maya | python | https://github.com/pyblish/pyblish-maya/blob/75db8b5d8de9d53ae95e74195a788b5f6db2cb5f/pyblish_maya/vendor/Qt.py#L422-L443 | [
"def",
"_maintain_backwards_compatibility",
"(",
"binding",
")",
":",
"for",
"member",
"in",
"(",
"\"__binding__\"",
",",
"\"__binding_version__\"",
",",
"\"__qt_version__\"",
",",
"\"__added__\"",
",",
"\"__remapped__\"",
",",
"\"__modified__\"",
",",
"\"convert\"",
",... | 75db8b5d8de9d53ae95e74195a788b5f6db2cb5f |
test | setup | Setup integration
Registers Pyblish for Maya plug-ins and appends an item to the File-menu
Attributes:
console (bool): Display console with GUI
port (int, optional): Port from which to start looking for an
available port to connect with Pyblish QML, default
provided by ... | pyblish_maya/lib.py | def setup(menu=True):
"""Setup integration
Registers Pyblish for Maya plug-ins and appends an item to the File-menu
Attributes:
console (bool): Display console with GUI
port (int, optional): Port from which to start looking for an
available port to connect with Pyblish QML, def... | def setup(menu=True):
"""Setup integration
Registers Pyblish for Maya plug-ins and appends an item to the File-menu
Attributes:
console (bool): Display console with GUI
port (int, optional): Port from which to start looking for an
available port to connect with Pyblish QML, def... | [
"Setup",
"integration"
] | pyblish/pyblish-maya | python | https://github.com/pyblish/pyblish-maya/blob/75db8b5d8de9d53ae95e74195a788b5f6db2cb5f/pyblish_maya/lib.py#L26-L50 | [
"def",
"setup",
"(",
"menu",
"=",
"True",
")",
":",
"if",
"self",
".",
"_has_been_setup",
":",
"teardown",
"(",
")",
"register_plugins",
"(",
")",
"register_host",
"(",
")",
"if",
"menu",
":",
"add_to_filemenu",
"(",
")",
"self",
".",
"_has_menu",
"=",
... | 75db8b5d8de9d53ae95e74195a788b5f6db2cb5f |
test | show | Try showing the most desirable GUI
This function cycles through the currently registered
graphical user interfaces, if any, and presents it to
the user. | pyblish_maya/lib.py | def show():
"""Try showing the most desirable GUI
This function cycles through the currently registered
graphical user interfaces, if any, and presents it to
the user.
"""
parent = next(
o for o in QtWidgets.QApplication.instance().topLevelWidgets()
if o.objectName() == "MayaW... | def show():
"""Try showing the most desirable GUI
This function cycles through the currently registered
graphical user interfaces, if any, and presents it to
the user.
"""
parent = next(
o for o in QtWidgets.QApplication.instance().topLevelWidgets()
if o.objectName() == "MayaW... | [
"Try",
"showing",
"the",
"most",
"desirable",
"GUI"
] | pyblish/pyblish-maya | python | https://github.com/pyblish/pyblish-maya/blob/75db8b5d8de9d53ae95e74195a788b5f6db2cb5f/pyblish_maya/lib.py#L53-L72 | [
"def",
"show",
"(",
")",
":",
"parent",
"=",
"next",
"(",
"o",
"for",
"o",
"in",
"QtWidgets",
".",
"QApplication",
".",
"instance",
"(",
")",
".",
"topLevelWidgets",
"(",
")",
"if",
"o",
".",
"objectName",
"(",
")",
"==",
"\"MayaWindow\"",
")",
"gui"... | 75db8b5d8de9d53ae95e74195a788b5f6db2cb5f |
test | _discover_gui | Return the most desirable of the currently registered GUIs | pyblish_maya/lib.py | def _discover_gui():
"""Return the most desirable of the currently registered GUIs"""
# Prefer last registered
guis = reversed(pyblish.api.registered_guis())
for gui in guis:
try:
gui = __import__(gui).show
except (ImportError, AttributeError):
continue
... | def _discover_gui():
"""Return the most desirable of the currently registered GUIs"""
# Prefer last registered
guis = reversed(pyblish.api.registered_guis())
for gui in guis:
try:
gui = __import__(gui).show
except (ImportError, AttributeError):
continue
... | [
"Return",
"the",
"most",
"desirable",
"of",
"the",
"currently",
"registered",
"GUIs"
] | pyblish/pyblish-maya | python | https://github.com/pyblish/pyblish-maya/blob/75db8b5d8de9d53ae95e74195a788b5f6db2cb5f/pyblish_maya/lib.py#L75-L87 | [
"def",
"_discover_gui",
"(",
")",
":",
"# Prefer last registered",
"guis",
"=",
"reversed",
"(",
"pyblish",
".",
"api",
".",
"registered_guis",
"(",
")",
")",
"for",
"gui",
"in",
"guis",
":",
"try",
":",
"gui",
"=",
"__import__",
"(",
"gui",
")",
".",
... | 75db8b5d8de9d53ae95e74195a788b5f6db2cb5f |
test | teardown | Remove integration | pyblish_maya/lib.py | def teardown():
"""Remove integration"""
if not self._has_been_setup:
return
deregister_plugins()
deregister_host()
if self._has_menu:
remove_from_filemenu()
self._has_menu = False
self._has_been_setup = False
print("pyblish: Integration torn down successfully") | def teardown():
"""Remove integration"""
if not self._has_been_setup:
return
deregister_plugins()
deregister_host()
if self._has_menu:
remove_from_filemenu()
self._has_menu = False
self._has_been_setup = False
print("pyblish: Integration torn down successfully") | [
"Remove",
"integration"
] | pyblish/pyblish-maya | python | https://github.com/pyblish/pyblish-maya/blob/75db8b5d8de9d53ae95e74195a788b5f6db2cb5f/pyblish_maya/lib.py#L90-L103 | [
"def",
"teardown",
"(",
")",
":",
"if",
"not",
"self",
".",
"_has_been_setup",
":",
"return",
"deregister_plugins",
"(",
")",
"deregister_host",
"(",
")",
"if",
"self",
".",
"_has_menu",
":",
"remove_from_filemenu",
"(",
")",
"self",
".",
"_has_menu",
"=",
... | 75db8b5d8de9d53ae95e74195a788b5f6db2cb5f |
test | deregister_host | Register supported hosts | pyblish_maya/lib.py | def deregister_host():
"""Register supported hosts"""
pyblish.api.deregister_host("mayabatch")
pyblish.api.deregister_host("mayapy")
pyblish.api.deregister_host("maya") | def deregister_host():
"""Register supported hosts"""
pyblish.api.deregister_host("mayabatch")
pyblish.api.deregister_host("mayapy")
pyblish.api.deregister_host("maya") | [
"Register",
"supported",
"hosts"
] | pyblish/pyblish-maya | python | https://github.com/pyblish/pyblish-maya/blob/75db8b5d8de9d53ae95e74195a788b5f6db2cb5f/pyblish_maya/lib.py#L120-L124 | [
"def",
"deregister_host",
"(",
")",
":",
"pyblish",
".",
"api",
".",
"deregister_host",
"(",
"\"mayabatch\"",
")",
"pyblish",
".",
"api",
".",
"deregister_host",
"(",
"\"mayapy\"",
")",
"pyblish",
".",
"api",
".",
"deregister_host",
"(",
"\"maya\"",
")"
] | 75db8b5d8de9d53ae95e74195a788b5f6db2cb5f |
test | add_to_filemenu | Add Pyblish to file-menu
.. note:: We're going a bit hacky here, probably due to my lack
of understanding for `evalDeferred` or `executeDeferred`,
so if you can think of a better solution, feel free to edit. | pyblish_maya/lib.py | def add_to_filemenu():
"""Add Pyblish to file-menu
.. note:: We're going a bit hacky here, probably due to my lack
of understanding for `evalDeferred` or `executeDeferred`,
so if you can think of a better solution, feel free to edit.
"""
if hasattr(cmds, 'about') and not cmds.about(ba... | def add_to_filemenu():
"""Add Pyblish to file-menu
.. note:: We're going a bit hacky here, probably due to my lack
of understanding for `evalDeferred` or `executeDeferred`,
so if you can think of a better solution, feel free to edit.
"""
if hasattr(cmds, 'about') and not cmds.about(ba... | [
"Add",
"Pyblish",
"to",
"file",
"-",
"menu"
] | pyblish/pyblish-maya | python | https://github.com/pyblish/pyblish-maya/blob/75db8b5d8de9d53ae95e74195a788b5f6db2cb5f/pyblish_maya/lib.py#L134-L156 | [
"def",
"add_to_filemenu",
"(",
")",
":",
"if",
"hasattr",
"(",
"cmds",
",",
"'about'",
")",
"and",
"not",
"cmds",
".",
"about",
"(",
"batch",
"=",
"True",
")",
":",
"# As Maya builds its menus dynamically upon being accessed,",
"# we force its build here prior to addi... | 75db8b5d8de9d53ae95e74195a788b5f6db2cb5f |
test | _add_to_filemenu | Helper function for the above :func:add_to_filemenu()
This function is serialised into a string and passed on
to evalDeferred above. | pyblish_maya/lib.py | def _add_to_filemenu():
"""Helper function for the above :func:add_to_filemenu()
This function is serialised into a string and passed on
to evalDeferred above.
"""
import os
import pyblish
from maya import cmds
# This must be duplicated here, due to this function
# not being avai... | def _add_to_filemenu():
"""Helper function for the above :func:add_to_filemenu()
This function is serialised into a string and passed on
to evalDeferred above.
"""
import os
import pyblish
from maya import cmds
# This must be duplicated here, due to this function
# not being avai... | [
"Helper",
"function",
"for",
"the",
"above",
":",
"func",
":",
"add_to_filemenu",
"()"
] | pyblish/pyblish-maya | python | https://github.com/pyblish/pyblish-maya/blob/75db8b5d8de9d53ae95e74195a788b5f6db2cb5f/pyblish_maya/lib.py#L167-L205 | [
"def",
"_add_to_filemenu",
"(",
")",
":",
"import",
"os",
"import",
"pyblish",
"from",
"maya",
"import",
"cmds",
"# This must be duplicated here, due to this function",
"# not being available through the above `evalDeferred`",
"for",
"item",
"in",
"(",
"\"pyblishOpeningDivider\... | 75db8b5d8de9d53ae95e74195a788b5f6db2cb5f |
test | maintained_selection | Maintain selection during context
Example:
>>> with maintained_selection():
... # Modify selection
... cmds.select('node', replace=True)
>>> # Selection restored | pyblish_maya/lib.py | def maintained_selection():
"""Maintain selection during context
Example:
>>> with maintained_selection():
... # Modify selection
... cmds.select('node', replace=True)
>>> # Selection restored
"""
previous_selection = cmds.ls(selection=True)
try:
yi... | def maintained_selection():
"""Maintain selection during context
Example:
>>> with maintained_selection():
... # Modify selection
... cmds.select('node', replace=True)
>>> # Selection restored
"""
previous_selection = cmds.ls(selection=True)
try:
yi... | [
"Maintain",
"selection",
"during",
"context"
] | pyblish/pyblish-maya | python | https://github.com/pyblish/pyblish-maya/blob/75db8b5d8de9d53ae95e74195a788b5f6db2cb5f/pyblish_maya/lib.py#L209-L230 | [
"def",
"maintained_selection",
"(",
")",
":",
"previous_selection",
"=",
"cmds",
".",
"ls",
"(",
"selection",
"=",
"True",
")",
"try",
":",
"yield",
"finally",
":",
"if",
"previous_selection",
":",
"cmds",
".",
"select",
"(",
"previous_selection",
",",
"repl... | 75db8b5d8de9d53ae95e74195a788b5f6db2cb5f |
test | maintained_time | Maintain current time during context
Example:
>>> with maintained_time():
... cmds.playblast()
>>> # Time restored | pyblish_maya/lib.py | def maintained_time():
"""Maintain current time during context
Example:
>>> with maintained_time():
... cmds.playblast()
>>> # Time restored
"""
ct = cmds.currentTime(query=True)
try:
yield
finally:
cmds.currentTime(ct, edit=True) | def maintained_time():
"""Maintain current time during context
Example:
>>> with maintained_time():
... cmds.playblast()
>>> # Time restored
"""
ct = cmds.currentTime(query=True)
try:
yield
finally:
cmds.currentTime(ct, edit=True) | [
"Maintain",
"current",
"time",
"during",
"context"
] | pyblish/pyblish-maya | python | https://github.com/pyblish/pyblish-maya/blob/75db8b5d8de9d53ae95e74195a788b5f6db2cb5f/pyblish_maya/lib.py#L234-L248 | [
"def",
"maintained_time",
"(",
")",
":",
"ct",
"=",
"cmds",
".",
"currentTime",
"(",
"query",
"=",
"True",
")",
"try",
":",
"yield",
"finally",
":",
"cmds",
".",
"currentTime",
"(",
"ct",
",",
"edit",
"=",
"True",
")"
] | 75db8b5d8de9d53ae95e74195a788b5f6db2cb5f |
test | _show_no_gui | Popup with information about how to register a new GUI
In the event of no GUI being registered or available,
this information dialog will appear to guide the user
through how to get set up with one. | pyblish_maya/lib.py | def _show_no_gui():
"""Popup with information about how to register a new GUI
In the event of no GUI being registered or available,
this information dialog will appear to guide the user
through how to get set up with one.
"""
messagebox = QtWidgets.QMessageBox()
messagebox.setIcon(message... | def _show_no_gui():
"""Popup with information about how to register a new GUI
In the event of no GUI being registered or available,
this information dialog will appear to guide the user
through how to get set up with one.
"""
messagebox = QtWidgets.QMessageBox()
messagebox.setIcon(message... | [
"Popup",
"with",
"information",
"about",
"how",
"to",
"register",
"a",
"new",
"GUI"
] | pyblish/pyblish-maya | python | https://github.com/pyblish/pyblish-maya/blob/75db8b5d8de9d53ae95e74195a788b5f6db2cb5f/pyblish_maya/lib.py#L251-L319 | [
"def",
"_show_no_gui",
"(",
")",
":",
"messagebox",
"=",
"QtWidgets",
".",
"QMessageBox",
"(",
")",
"messagebox",
".",
"setIcon",
"(",
"messagebox",
".",
"Warning",
")",
"messagebox",
".",
"setWindowIcon",
"(",
"QtGui",
".",
"QIcon",
"(",
"os",
".",
"path"... | 75db8b5d8de9d53ae95e74195a788b5f6db2cb5f |
test | Field.setup_types | The Message object has a circular reference on itself, thus we have to allow
Type referencing by name. Here we lookup any Types referenced by name and
replace with the real class. | TelegramBotAPI/types/field.py | def setup_types(self):
"""
The Message object has a circular reference on itself, thus we have to allow
Type referencing by name. Here we lookup any Types referenced by name and
replace with the real class.
"""
def load(t):
from TelegramBotAPI.types.type impor... | def setup_types(self):
"""
The Message object has a circular reference on itself, thus we have to allow
Type referencing by name. Here we lookup any Types referenced by name and
replace with the real class.
"""
def load(t):
from TelegramBotAPI.types.type impor... | [
"The",
"Message",
"object",
"has",
"a",
"circular",
"reference",
"on",
"itself",
"thus",
"we",
"have",
"to",
"allow",
"Type",
"referencing",
"by",
"name",
".",
"Here",
"we",
"lookup",
"any",
"Types",
"referenced",
"by",
"name",
"and",
"replace",
"with",
"t... | sourcesimian/pyTelegramBotAPI | python | https://github.com/sourcesimian/pyTelegramBotAPI/blob/bf233ac7923cc97c2036a604922c8be57817db40/TelegramBotAPI/types/field.py#L24-L36 | [
"def",
"setup_types",
"(",
"self",
")",
":",
"def",
"load",
"(",
"t",
")",
":",
"from",
"TelegramBotAPI",
".",
"types",
".",
"type",
"import",
"Type",
"if",
"isinstance",
"(",
"t",
",",
"str",
")",
":",
"return",
"Type",
".",
"_type",
"(",
"t",
")"... | bf233ac7923cc97c2036a604922c8be57817db40 |
test | Line.get_cumulative_data | Get the data as it will be charted. The first set will be
the actual first data set. The second will be the sum of the
first and the second, etc. | svg/charts/line.py | def get_cumulative_data(self):
"""Get the data as it will be charted. The first set will be
the actual first data set. The second will be the sum of the
first and the second, etc."""
sets = map(itemgetter('data'), self.data)
if not sets:
return
sum = sets.pop(0)
yield sum
while sets:
sum = map(a... | def get_cumulative_data(self):
"""Get the data as it will be charted. The first set will be
the actual first data set. The second will be the sum of the
first and the second, etc."""
sets = map(itemgetter('data'), self.data)
if not sets:
return
sum = sets.pop(0)
yield sum
while sets:
sum = map(a... | [
"Get",
"the",
"data",
"as",
"it",
"will",
"be",
"charted",
".",
"The",
"first",
"set",
"will",
"be",
"the",
"actual",
"first",
"data",
"set",
".",
"The",
"second",
"will",
"be",
"the",
"sum",
"of",
"the",
"first",
"and",
"the",
"second",
"etc",
"."
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/line.py#L46-L57 | [
"def",
"get_cumulative_data",
"(",
"self",
")",
":",
"sets",
"=",
"map",
"(",
"itemgetter",
"(",
"'data'",
")",
",",
"self",
".",
"data",
")",
"if",
"not",
"sets",
":",
"return",
"sum",
"=",
"sets",
".",
"pop",
"(",
"0",
")",
"yield",
"sum",
"while... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Plot.get_single_axis_values | Return all the values for a single axis of the data. | svg/charts/plot.py | def get_single_axis_values(self, axis, dataset):
"""
Return all the values for a single axis of the data.
"""
data_index = getattr(self, '%s_data_index' % axis)
return [p[data_index] for p in dataset['data']] | def get_single_axis_values(self, axis, dataset):
"""
Return all the values for a single axis of the data.
"""
data_index = getattr(self, '%s_data_index' % axis)
return [p[data_index] for p in dataset['data']] | [
"Return",
"all",
"the",
"values",
"for",
"a",
"single",
"axis",
"of",
"the",
"data",
"."
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/plot.py#L195-L200 | [
"def",
"get_single_axis_values",
"(",
"self",
",",
"axis",
",",
"dataset",
")",
":",
"data_index",
"=",
"getattr",
"(",
"self",
",",
"'%s_data_index'",
"%",
"axis",
")",
"return",
"[",
"p",
"[",
"data_index",
"]",
"for",
"p",
"in",
"dataset",
"[",
"'data... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Plot.__draw_constant_line | Draw a constant line on the y-axis with the label | svg/charts/plot.py | def __draw_constant_line(self, value_label_style):
"Draw a constant line on the y-axis with the label"
value, label, style = value_label_style
start = self.transform_output_coordinates((0, value))[1]
stop = self.graph_width
path = etree.SubElement(self.graph, 'path', {
'd': 'M 0 %(start)s h%(stop)s' % loca... | def __draw_constant_line(self, value_label_style):
"Draw a constant line on the y-axis with the label"
value, label, style = value_label_style
start = self.transform_output_coordinates((0, value))[1]
stop = self.graph_width
path = etree.SubElement(self.graph, 'path', {
'd': 'M 0 %(start)s h%(stop)s' % loca... | [
"Draw",
"a",
"constant",
"line",
"on",
"the",
"y",
"-",
"axis",
"with",
"the",
"label"
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/plot.py#L326-L340 | [
"def",
"__draw_constant_line",
"(",
"self",
",",
"value_label_style",
")",
":",
"value",
",",
"label",
",",
"style",
"=",
"value_label_style",
"start",
"=",
"self",
".",
"transform_output_coordinates",
"(",
"(",
"0",
",",
"value",
")",
")",
"[",
"1",
"]",
... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Plot.load_transform_parameters | Cache the parameters necessary to transform x & y coordinates | svg/charts/plot.py | def load_transform_parameters(self):
"Cache the parameters necessary to transform x & y coordinates"
x_min, x_max, x_div = self.x_range()
y_min, y_max, y_div = self.y_range()
x_step = (float(self.graph_width) - self.font_size * 2) / \
(x_max - x_min)
y_step = (float(self.graph_height) - self.font_size * 2)... | def load_transform_parameters(self):
"Cache the parameters necessary to transform x & y coordinates"
x_min, x_max, x_div = self.x_range()
y_min, y_max, y_div = self.y_range()
x_step = (float(self.graph_width) - self.font_size * 2) / \
(x_max - x_min)
y_step = (float(self.graph_height) - self.font_size * 2)... | [
"Cache",
"the",
"parameters",
"necessary",
"to",
"transform",
"x",
"&",
"y",
"coordinates"
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/plot.py#L342-L351 | [
"def",
"load_transform_parameters",
"(",
"self",
")",
":",
"x_min",
",",
"x_max",
",",
"x_div",
"=",
"self",
".",
"x_range",
"(",
")",
"y_min",
",",
"y_max",
",",
"y_div",
"=",
"self",
".",
"y_range",
"(",
")",
"x_step",
"=",
"(",
"float",
"(",
"self... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | reverse_mapping | For every key, value pair, return the mapping for the
equivalent value, key pair
>>> reverse_mapping({'a': 'b'}) == {'b': 'a'}
True | svg/charts/util.py | def reverse_mapping(mapping):
"""
For every key, value pair, return the mapping for the
equivalent value, key pair
>>> reverse_mapping({'a': 'b'}) == {'b': 'a'}
True
"""
keys, values = zip(*mapping.items())
return dict(zip(values, keys)) | def reverse_mapping(mapping):
"""
For every key, value pair, return the mapping for the
equivalent value, key pair
>>> reverse_mapping({'a': 'b'}) == {'b': 'a'}
True
"""
keys, values = zip(*mapping.items())
return dict(zip(values, keys)) | [
"For",
"every",
"key",
"value",
"pair",
"return",
"the",
"mapping",
"for",
"the",
"equivalent",
"value",
"key",
"pair"
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/util.py#L4-L13 | [
"def",
"reverse_mapping",
"(",
"mapping",
")",
":",
"keys",
",",
"values",
"=",
"zip",
"(",
"*",
"mapping",
".",
"items",
"(",
")",
")",
"return",
"dict",
"(",
"zip",
"(",
"values",
",",
"keys",
")",
")"
] | 23053497b3f1af4e760f355050107ae3bc05909d |
test | flatten_mapping | For every key that has an __iter__ method, assign the values
to a key for each.
>>> flatten_mapping({'ab': 3, ('c','d'): 4}) == {'ab': 3, 'c': 4, 'd': 4}
True | svg/charts/util.py | def flatten_mapping(mapping):
"""
For every key that has an __iter__ method, assign the values
to a key for each.
>>> flatten_mapping({'ab': 3, ('c','d'): 4}) == {'ab': 3, 'c': 4, 'd': 4}
True
"""
return {
key: value
for keys, value in mapping.items()
for key in always_iterable(keys)
} | def flatten_mapping(mapping):
"""
For every key that has an __iter__ method, assign the values
to a key for each.
>>> flatten_mapping({'ab': 3, ('c','d'): 4}) == {'ab': 3, 'c': 4, 'd': 4}
True
"""
return {
key: value
for keys, value in mapping.items()
for key in always_iterable(keys)
} | [
"For",
"every",
"key",
"that",
"has",
"an",
"__iter__",
"method",
"assign",
"the",
"values",
"to",
"a",
"key",
"for",
"each",
"."
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/util.py#L16-L28 | [
"def",
"flatten_mapping",
"(",
"mapping",
")",
":",
"return",
"{",
"key",
":",
"value",
"for",
"keys",
",",
"value",
"in",
"mapping",
".",
"items",
"(",
")",
"for",
"key",
"in",
"always_iterable",
"(",
"keys",
")",
"}"
] | 23053497b3f1af4e760f355050107ae3bc05909d |
test | float_range | Much like the built-in function range, but accepts floats
>>> tuple(float_range(0, 9, 1.5))
(0.0, 1.5, 3.0, 4.5, 6.0, 7.5) | svg/charts/util.py | def float_range(start=0, stop=None, step=1):
"""
Much like the built-in function range, but accepts floats
>>> tuple(float_range(0, 9, 1.5))
(0.0, 1.5, 3.0, 4.5, 6.0, 7.5)
"""
start = float(start)
while start < stop:
yield start
start += step | def float_range(start=0, stop=None, step=1):
"""
Much like the built-in function range, but accepts floats
>>> tuple(float_range(0, 9, 1.5))
(0.0, 1.5, 3.0, 4.5, 6.0, 7.5)
"""
start = float(start)
while start < stop:
yield start
start += step | [
"Much",
"like",
"the",
"built",
"-",
"in",
"function",
"range",
"but",
"accepts",
"floats"
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/util.py#L31-L41 | [
"def",
"float_range",
"(",
"start",
"=",
"0",
",",
"stop",
"=",
"None",
",",
"step",
"=",
"1",
")",
":",
"start",
"=",
"float",
"(",
"start",
")",
"while",
"start",
"<",
"stop",
":",
"yield",
"start",
"start",
"+=",
"step"
] | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Pie.add_data | Add a data set to the graph
>>> graph.add_data({data:[1,2,3,4]}) # doctest: +SKIP
Note that a 'title' key is ignored.
Multiple calls to add_data will sum the elements, and the pie will
display the aggregated data. e.g.
>>> graph.add_data({data:[1,2,3,4]}) # doctest: +SKIP
>>> graph.add_data({data:[2,3,... | svg/charts/pie.py | def add_data(self, data_descriptor):
"""
Add a data set to the graph
>>> graph.add_data({data:[1,2,3,4]}) # doctest: +SKIP
Note that a 'title' key is ignored.
Multiple calls to add_data will sum the elements, and the pie will
display the aggregated data. e.g.
>>> graph.add_data({data:[1,2,3,4]}) # do... | def add_data(self, data_descriptor):
"""
Add a data set to the graph
>>> graph.add_data({data:[1,2,3,4]}) # doctest: +SKIP
Note that a 'title' key is ignored.
Multiple calls to add_data will sum the elements, and the pie will
display the aggregated data. e.g.
>>> graph.add_data({data:[1,2,3,4]}) # do... | [
"Add",
"a",
"data",
"set",
"to",
"the",
"graph"
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/pie.py#L83-L117 | [
"def",
"add_data",
"(",
"self",
",",
"data_descriptor",
")",
":",
"pairs",
"=",
"itertools",
".",
"zip_longest",
"(",
"self",
".",
"data",
",",
"data_descriptor",
"[",
"'data'",
"]",
")",
"self",
".",
"data",
"=",
"list",
"(",
"itertools",
".",
"starmap"... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Pie.add_defs | Add svg definitions | svg/charts/pie.py | def add_defs(self, defs):
"Add svg definitions"
etree.SubElement(
defs,
'filter',
id='dropshadow',
width='1.2',
height='1.2',
)
etree.SubElement(
defs,
'feGaussianBlur',
stdDeviation='4',
result='blur',
) | def add_defs(self, defs):
"Add svg definitions"
etree.SubElement(
defs,
'filter',
id='dropshadow',
width='1.2',
height='1.2',
)
etree.SubElement(
defs,
'feGaussianBlur',
stdDeviation='4',
result='blur',
) | [
"Add",
"svg",
"definitions"
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/pie.py#L119-L133 | [
"def",
"add_defs",
"(",
"self",
",",
"defs",
")",
":",
"etree",
".",
"SubElement",
"(",
"defs",
",",
"'filter'",
",",
"id",
"=",
"'dropshadow'",
",",
"width",
"=",
"'1.2'",
",",
"height",
"=",
"'1.2'",
",",
")",
"etree",
".",
"SubElement",
"(",
"defs... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Graph.add_data | Add data to the graph object. May be called several times to add
additional data sets.
conf should be a dictionary including 'data' and 'title' keys | svg/charts/graph.py | def add_data(self, conf):
"""
Add data to the graph object. May be called several times to add
additional data sets.
conf should be a dictionary including 'data' and 'title' keys
"""
self.validate_data(conf)
self.process_data(conf)
self.data.append(conf) | def add_data(self, conf):
"""
Add data to the graph object. May be called several times to add
additional data sets.
conf should be a dictionary including 'data' and 'title' keys
"""
self.validate_data(conf)
self.process_data(conf)
self.data.append(conf) | [
"Add",
"data",
"to",
"the",
"graph",
"object",
".",
"May",
"be",
"called",
"several",
"times",
"to",
"add",
"additional",
"data",
"sets",
"."
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/graph.py#L100-L109 | [
"def",
"add_data",
"(",
"self",
",",
"conf",
")",
":",
"self",
".",
"validate_data",
"(",
"conf",
")",
"self",
".",
"process_data",
"(",
"conf",
")",
"self",
".",
"data",
".",
"append",
"(",
"conf",
")"
] | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Graph.burn | Process the template with the data and
config which has been set and return the resulting SVG.
Raises ValueError when no data set has
been added to the graph object. | svg/charts/graph.py | def burn(self):
"""
Process the template with the data and
config which has been set and return the resulting SVG.
Raises ValueError when no data set has
been added to the graph object.
"""
if not self.data:
raise ValueError("No data available")
if hasattr(self, 'calculations'):
self.calculation... | def burn(self):
"""
Process the template with the data and
config which has been set and return the resulting SVG.
Raises ValueError when no data set has
been added to the graph object.
"""
if not self.data:
raise ValueError("No data available")
if hasattr(self, 'calculations'):
self.calculation... | [
"Process",
"the",
"template",
"with",
"the",
"data",
"and",
"config",
"which",
"has",
"been",
"set",
"and",
"return",
"the",
"resulting",
"SVG",
"."
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/graph.py#L135-L159 | [
"def",
"burn",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"data",
":",
"raise",
"ValueError",
"(",
"\"No data available\"",
")",
"if",
"hasattr",
"(",
"self",
",",
"'calculations'",
")",
":",
"self",
".",
"calculations",
"(",
")",
"self",
".",
"s... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Graph.calculate_left_margin | Calculates the margin to the left of the plot area, setting
border_left. | svg/charts/graph.py | def calculate_left_margin(self):
"""
Calculates the margin to the left of the plot area, setting
border_left.
"""
bl = 7
# Check for Y labels
if self.rotate_y_labels:
max_y_label_height_px = self.y_label_font_size
else:
label_lengths = map(len, self.get_y_labels())
max_y_label_len = max(label_l... | def calculate_left_margin(self):
"""
Calculates the margin to the left of the plot area, setting
border_left.
"""
bl = 7
# Check for Y labels
if self.rotate_y_labels:
max_y_label_height_px = self.y_label_font_size
else:
label_lengths = map(len, self.get_y_labels())
max_y_label_len = max(label_l... | [
"Calculates",
"the",
"margin",
"to",
"the",
"left",
"of",
"the",
"plot",
"area",
"setting",
"border_left",
"."
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/graph.py#L167-L186 | [
"def",
"calculate_left_margin",
"(",
"self",
")",
":",
"bl",
"=",
"7",
"# Check for Y labels",
"if",
"self",
".",
"rotate_y_labels",
":",
"max_y_label_height_px",
"=",
"self",
".",
"y_label_font_size",
"else",
":",
"label_lengths",
"=",
"map",
"(",
"len",
",",
... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Graph.calculate_right_margin | Calculate the margin in pixels to the right of the plot area,
setting border_right. | svg/charts/graph.py | def calculate_right_margin(self):
"""
Calculate the margin in pixels to the right of the plot area,
setting border_right.
"""
br = 7
if self.key and self.key_position == 'right':
max_key_len = max(map(len, self.keys()))
br += max_key_len * self.key_font_size * 0.6
br += self.KEY_BOX_SIZE
br += 1... | def calculate_right_margin(self):
"""
Calculate the margin in pixels to the right of the plot area,
setting border_right.
"""
br = 7
if self.key and self.key_position == 'right':
max_key_len = max(map(len, self.keys()))
br += max_key_len * self.key_font_size * 0.6
br += self.KEY_BOX_SIZE
br += 1... | [
"Calculate",
"the",
"margin",
"in",
"pixels",
"to",
"the",
"right",
"of",
"the",
"plot",
"area",
"setting",
"border_right",
"."
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/graph.py#L196-L207 | [
"def",
"calculate_right_margin",
"(",
"self",
")",
":",
"br",
"=",
"7",
"if",
"self",
".",
"key",
"and",
"self",
".",
"key_position",
"==",
"'right'",
":",
"max_key_len",
"=",
"max",
"(",
"map",
"(",
"len",
",",
"self",
".",
"keys",
"(",
")",
")",
... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Graph.calculate_top_margin | Calculate the margin in pixels above the plot area, setting
border_top. | svg/charts/graph.py | def calculate_top_margin(self):
"""
Calculate the margin in pixels above the plot area, setting
border_top.
"""
self.border_top = 5
if self.show_graph_title:
self.border_top += self.title_font_size
self.border_top += 5
if self.show_graph_subtitle:
self.border_top += self.subtitle_font_size | def calculate_top_margin(self):
"""
Calculate the margin in pixels above the plot area, setting
border_top.
"""
self.border_top = 5
if self.show_graph_title:
self.border_top += self.title_font_size
self.border_top += 5
if self.show_graph_subtitle:
self.border_top += self.subtitle_font_size | [
"Calculate",
"the",
"margin",
"in",
"pixels",
"above",
"the",
"plot",
"area",
"setting",
"border_top",
"."
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/graph.py#L209-L219 | [
"def",
"calculate_top_margin",
"(",
"self",
")",
":",
"self",
".",
"border_top",
"=",
"5",
"if",
"self",
".",
"show_graph_title",
":",
"self",
".",
"border_top",
"+=",
"self",
".",
"title_font_size",
"self",
".",
"border_top",
"+=",
"5",
"if",
"self",
".",... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Graph.add_popup | Add pop-up information to a point on the graph. | svg/charts/graph.py | def add_popup(self, x, y, label):
"""
Add pop-up information to a point on the graph.
"""
txt_width = len(label) * self.font_size * 0.6 + 10
tx = x + [5, -5][int(x + txt_width > self.width)]
anchor = ['start', 'end'][x + txt_width > self.width]
style = 'fill: #000; text-anchor: %s;' % anchor
id = 'label... | def add_popup(self, x, y, label):
"""
Add pop-up information to a point on the graph.
"""
txt_width = len(label) * self.font_size * 0.6 + 10
tx = x + [5, -5][int(x + txt_width > self.width)]
anchor = ['start', 'end'][x + txt_width > self.width]
style = 'fill: #000; text-anchor: %s;' % anchor
id = 'label... | [
"Add",
"pop",
"-",
"up",
"information",
"to",
"a",
"point",
"on",
"the",
"graph",
"."
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/graph.py#L230-L261 | [
"def",
"add_popup",
"(",
"self",
",",
"x",
",",
"y",
",",
"label",
")",
":",
"txt_width",
"=",
"len",
"(",
"label",
")",
"*",
"self",
".",
"font_size",
"*",
"0.6",
"+",
"10",
"tx",
"=",
"x",
"+",
"[",
"5",
",",
"-",
"5",
"]",
"[",
"int",
"(... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Graph.calculate_bottom_margin | Calculate the margin in pixels below the plot area, setting
border_bottom. | svg/charts/graph.py | def calculate_bottom_margin(self):
"""
Calculate the margin in pixels below the plot area, setting
border_bottom.
"""
bb = 7
if self.key and self.key_position == 'bottom':
bb += len(self.data) * (self.font_size + 5)
bb += 10
if self.show_x_labels:
max_x_label_height_px = self.x_label_font_size
... | def calculate_bottom_margin(self):
"""
Calculate the margin in pixels below the plot area, setting
border_bottom.
"""
bb = 7
if self.key and self.key_position == 'bottom':
bb += len(self.data) * (self.font_size + 5)
bb += 10
if self.show_x_labels:
max_x_label_height_px = self.x_label_font_size
... | [
"Calculate",
"the",
"margin",
"in",
"pixels",
"below",
"the",
"plot",
"area",
"setting",
"border_bottom",
"."
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/graph.py#L263-L283 | [
"def",
"calculate_bottom_margin",
"(",
"self",
")",
":",
"bb",
"=",
"7",
"if",
"self",
".",
"key",
"and",
"self",
".",
"key_position",
"==",
"'bottom'",
":",
"bb",
"+=",
"len",
"(",
"self",
".",
"data",
")",
"*",
"(",
"self",
".",
"font_size",
"+",
... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Graph.draw_graph | The central logic for drawing the graph.
Sets self.graph (the 'g' element in the SVG root) | svg/charts/graph.py | def draw_graph(self):
"""
The central logic for drawing the graph.
Sets self.graph (the 'g' element in the SVG root)
"""
transform = 'translate (%s %s)' % (self.border_left, self.border_top)
self.graph = etree.SubElement(self.root, 'g', transform=transform)
etree.SubElement(self.graph, 'rect', {
'x':... | def draw_graph(self):
"""
The central logic for drawing the graph.
Sets self.graph (the 'g' element in the SVG root)
"""
transform = 'translate (%s %s)' % (self.border_left, self.border_top)
self.graph = etree.SubElement(self.root, 'g', transform=transform)
etree.SubElement(self.graph, 'rect', {
'x':... | [
"The",
"central",
"logic",
"for",
"drawing",
"the",
"graph",
"."
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/graph.py#L285-L315 | [
"def",
"draw_graph",
"(",
"self",
")",
":",
"transform",
"=",
"'translate (%s %s)'",
"%",
"(",
"self",
".",
"border_left",
",",
"self",
".",
"border_top",
")",
"self",
".",
"graph",
"=",
"etree",
".",
"SubElement",
"(",
"self",
".",
"root",
",",
"'g'",
... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Graph.make_datapoint_text | Add text for a datapoint | svg/charts/graph.py | def make_datapoint_text(self, x, y, value, style=None):
"""
Add text for a datapoint
"""
if not self.show_data_values:
# do nothing
return
# first lay down the text in a wide white stroke to
# differentiate it from the background
e = etree.SubElement(self.foreground, 'text', {
'x': str(x),
'y... | def make_datapoint_text(self, x, y, value, style=None):
"""
Add text for a datapoint
"""
if not self.show_data_values:
# do nothing
return
# first lay down the text in a wide white stroke to
# differentiate it from the background
e = etree.SubElement(self.foreground, 'text', {
'x': str(x),
'y... | [
"Add",
"text",
"for",
"a",
"datapoint"
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/graph.py#L324-L347 | [
"def",
"make_datapoint_text",
"(",
"self",
",",
"x",
",",
"y",
",",
"value",
",",
"style",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"show_data_values",
":",
"# do nothing",
"return",
"# first lay down the text in a wide white stroke to",
"# differentiate it... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Graph.draw_x_labels | Draw the X axis labels | svg/charts/graph.py | def draw_x_labels(self):
"Draw the X axis labels"
if self.show_x_labels:
labels = self.get_x_labels()
count = len(labels)
labels = enumerate(iter(labels))
start = int(not self.step_include_first_x_label)
labels = itertools.islice(labels, start, None, self.step_x_labels)
list(map(self.draw_x_label... | def draw_x_labels(self):
"Draw the X axis labels"
if self.show_x_labels:
labels = self.get_x_labels()
count = len(labels)
labels = enumerate(iter(labels))
start = int(not self.step_include_first_x_label)
labels = itertools.islice(labels, start, None, self.step_x_labels)
list(map(self.draw_x_label... | [
"Draw",
"the",
"X",
"axis",
"labels"
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/graph.py#L349-L359 | [
"def",
"draw_x_labels",
"(",
"self",
")",
":",
"if",
"self",
".",
"show_x_labels",
":",
"labels",
"=",
"self",
".",
"get_x_labels",
"(",
")",
"count",
"=",
"len",
"(",
"labels",
")",
"labels",
"=",
"enumerate",
"(",
"iter",
"(",
"labels",
")",
")",
"... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Graph.draw_y_labels | Draw the Y axis labels | svg/charts/graph.py | def draw_y_labels(self):
"Draw the Y axis labels"
if not self.show_y_labels:
# do nothing
return
labels = self.get_y_labels()
count = len(labels)
labels = enumerate(iter(labels))
start = int(not self.step_include_first_y_label)
labels = itertools.islice(labels, start, None, self.step_y_labels)
l... | def draw_y_labels(self):
"Draw the Y axis labels"
if not self.show_y_labels:
# do nothing
return
labels = self.get_y_labels()
count = len(labels)
labels = enumerate(iter(labels))
start = int(not self.step_include_first_y_label)
labels = itertools.islice(labels, start, None, self.step_y_labels)
l... | [
"Draw",
"the",
"Y",
"axis",
"labels"
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/graph.py#L406-L419 | [
"def",
"draw_y_labels",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"show_y_labels",
":",
"# do nothing",
"return",
"labels",
"=",
"self",
".",
"get_y_labels",
"(",
")",
"count",
"=",
"len",
"(",
"labels",
")",
"labels",
"=",
"enumerate",
"(",
"iter... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Graph.draw_x_guidelines | Draw the X-axis guidelines | svg/charts/graph.py | def draw_x_guidelines(self, label_height, count):
"Draw the X-axis guidelines"
if not self.show_x_guidelines:
return
# skip the first one
for count in range(1, count):
move = 'M {start} 0 v{stop}'.format(
start=label_height * count,
stop=self.graph_height,
)
path = {'d': move, 'class': 'guid... | def draw_x_guidelines(self, label_height, count):
"Draw the X-axis guidelines"
if not self.show_x_guidelines:
return
# skip the first one
for count in range(1, count):
move = 'M {start} 0 v{stop}'.format(
start=label_height * count,
stop=self.graph_height,
)
path = {'d': move, 'class': 'guid... | [
"Draw",
"the",
"X",
"-",
"axis",
"guidelines"
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/graph.py#L457-L468 | [
"def",
"draw_x_guidelines",
"(",
"self",
",",
"label_height",
",",
"count",
")",
":",
"if",
"not",
"self",
".",
"show_x_guidelines",
":",
"return",
"# skip the first one",
"for",
"count",
"in",
"range",
"(",
"1",
",",
"count",
")",
":",
"move",
"=",
"'M {s... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Graph.draw_y_guidelines | Draw the Y-axis guidelines | svg/charts/graph.py | def draw_y_guidelines(self, label_height, count):
"Draw the Y-axis guidelines"
if not self.show_y_guidelines:
return
for count in range(1, count):
move = 'M 0 {start} h{stop}'.format(
start=self.graph_height - label_height * count,
stop=self.graph_width,
)
path = {'d': move, 'class': 'guideLin... | def draw_y_guidelines(self, label_height, count):
"Draw the Y-axis guidelines"
if not self.show_y_guidelines:
return
for count in range(1, count):
move = 'M 0 {start} h{stop}'.format(
start=self.graph_height - label_height * count,
stop=self.graph_width,
)
path = {'d': move, 'class': 'guideLin... | [
"Draw",
"the",
"Y",
"-",
"axis",
"guidelines"
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/graph.py#L470-L480 | [
"def",
"draw_y_guidelines",
"(",
"self",
",",
"label_height",
",",
"count",
")",
":",
"if",
"not",
"self",
".",
"show_y_guidelines",
":",
"return",
"for",
"count",
"in",
"range",
"(",
"1",
",",
"count",
")",
":",
"move",
"=",
"'M 0 {start} h{stop}'",
".",
... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Graph.draw_titles | Draws the graph title and subtitle | svg/charts/graph.py | def draw_titles(self):
"Draws the graph title and subtitle"
if self.show_graph_title:
self.draw_graph_title()
if self.show_graph_subtitle:
self.draw_graph_subtitle()
if self.show_x_title:
self.draw_x_title()
if self.show_y_title:
self.draw_y_title() | def draw_titles(self):
"Draws the graph title and subtitle"
if self.show_graph_title:
self.draw_graph_title()
if self.show_graph_subtitle:
self.draw_graph_subtitle()
if self.show_x_title:
self.draw_x_title()
if self.show_y_title:
self.draw_y_title() | [
"Draws",
"the",
"graph",
"title",
"and",
"subtitle"
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/graph.py#L482-L491 | [
"def",
"draw_titles",
"(",
"self",
")",
":",
"if",
"self",
".",
"show_graph_title",
":",
"self",
".",
"draw_graph_title",
"(",
")",
"if",
"self",
".",
"show_graph_subtitle",
":",
"self",
".",
"draw_graph_subtitle",
"(",
")",
"if",
"self",
".",
"show_x_title"... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Graph.render_inline_styles | Hard-code the styles into the SVG XML if style sheets are not used. | svg/charts/graph.py | def render_inline_styles(self):
"Hard-code the styles into the SVG XML if style sheets are not used."
if not self.css_inline:
# do nothing
return
styles = self.parse_css()
for node in self.root.xpath('//*[@class]'):
cl = '.' + node.attrib['class']
if cl not in styles:
continue
style = styles... | def render_inline_styles(self):
"Hard-code the styles into the SVG XML if style sheets are not used."
if not self.css_inline:
# do nothing
return
styles = self.parse_css()
for node in self.root.xpath('//*[@class]'):
cl = '.' + node.attrib['class']
if cl not in styles:
continue
style = styles... | [
"Hard",
"-",
"code",
"the",
"styles",
"into",
"the",
"SVG",
"XML",
"if",
"style",
"sheets",
"are",
"not",
"used",
"."
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/graph.py#L592-L606 | [
"def",
"render_inline_styles",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"css_inline",
":",
"# do nothing",
"return",
"styles",
"=",
"self",
".",
"parse_css",
"(",
")",
"for",
"node",
"in",
"self",
".",
"root",
".",
"xpath",
"(",
"'//*[@class]'",
... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Graph.parse_css | Take a .css file (classes only please) and parse it into a dictionary
of class/style pairs. | svg/charts/graph.py | def parse_css(self):
"""
Take a .css file (classes only please) and parse it into a dictionary
of class/style pairs.
"""
# todo: save the prefs for use later
# orig_prefs = cssutils.ser.prefs
cssutils.ser.prefs.useMinified()
pairs = (
(r.selectorText, r.style.cssText)
for r in self.get_stylesheet(... | def parse_css(self):
"""
Take a .css file (classes only please) and parse it into a dictionary
of class/style pairs.
"""
# todo: save the prefs for use later
# orig_prefs = cssutils.ser.prefs
cssutils.ser.prefs.useMinified()
pairs = (
(r.selectorText, r.style.cssText)
for r in self.get_stylesheet(... | [
"Take",
"a",
".",
"css",
"file",
"(",
"classes",
"only",
"please",
")",
"and",
"parse",
"it",
"into",
"a",
"dictionary",
"of",
"class",
"/",
"style",
"pairs",
"."
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/graph.py#L608-L621 | [
"def",
"parse_css",
"(",
"self",
")",
":",
"# todo: save the prefs for use later",
"# orig_prefs = cssutils.ser.prefs",
"cssutils",
".",
"ser",
".",
"prefs",
".",
"useMinified",
"(",
")",
"pairs",
"=",
"(",
"(",
"r",
".",
"selectorText",
",",
"r",
".",
"style",
... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Graph.start_svg | Base SVG Document Creation | svg/charts/graph.py | def start_svg(self):
"Base SVG Document Creation"
SVG_NAMESPACE = 'http://www.w3.org/2000/svg'
SVG = '{%s}' % SVG_NAMESPACE
NSMAP = {
None: SVG_NAMESPACE,
'xlink': 'http://www.w3.org/1999/xlink',
'a3': 'http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/',
}
root_attrs = self._get_root_attributes()
... | def start_svg(self):
"Base SVG Document Creation"
SVG_NAMESPACE = 'http://www.w3.org/2000/svg'
SVG = '{%s}' % SVG_NAMESPACE
NSMAP = {
None: SVG_NAMESPACE,
'xlink': 'http://www.w3.org/1999/xlink',
'a3': 'http://ns.adobe.com/AdobeSVGViewerExtensions/3.0/',
}
root_attrs = self._get_root_attributes()
... | [
"Base",
"SVG",
"Document",
"Creation"
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/graph.py#L637-L681 | [
"def",
"start_svg",
"(",
"self",
")",
":",
"SVG_NAMESPACE",
"=",
"'http://www.w3.org/2000/svg'",
"SVG",
"=",
"'{%s}'",
"%",
"SVG_NAMESPACE",
"NSMAP",
"=",
"{",
"None",
":",
"SVG_NAMESPACE",
",",
"'xlink'",
":",
"'http://www.w3.org/1999/xlink'",
",",
"'a3'",
":",
... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | Graph.get_stylesheet_resources | Get the stylesheets for this instance | svg/charts/graph.py | def get_stylesheet_resources(self):
"Get the stylesheets for this instance"
# allow css to include class variables
class_vars = class_dict(self)
loader = functools.partial(
self.load_resource_stylesheet,
subs=class_vars)
sheets = list(map(loader, self.stylesheet_names))
return sheets | def get_stylesheet_resources(self):
"Get the stylesheets for this instance"
# allow css to include class variables
class_vars = class_dict(self)
loader = functools.partial(
self.load_resource_stylesheet,
subs=class_vars)
sheets = list(map(loader, self.stylesheet_names))
return sheets | [
"Get",
"the",
"stylesheets",
"for",
"this",
"instance"
] | jaraco/svg.charts | python | https://github.com/jaraco/svg.charts/blob/23053497b3f1af4e760f355050107ae3bc05909d/svg/charts/graph.py#L697-L705 | [
"def",
"get_stylesheet_resources",
"(",
"self",
")",
":",
"# allow css to include class variables",
"class_vars",
"=",
"class_dict",
"(",
"self",
")",
"loader",
"=",
"functools",
".",
"partial",
"(",
"self",
".",
"load_resource_stylesheet",
",",
"subs",
"=",
"class_... | 23053497b3f1af4e760f355050107ae3bc05909d |
test | run_bot | \
Convenience function to start a bot on the given network, optionally joining
some channels | irc.py | def run_bot(bot_class, host, port, nick, channels=None, ssl=None):
"""\
Convenience function to start a bot on the given network, optionally joining
some channels
"""
conn = IRCConnection(host, port, nick, ssl)
bot_instance = bot_class(conn)
while 1:
if not conn.connect():
... | def run_bot(bot_class, host, port, nick, channels=None, ssl=None):
"""\
Convenience function to start a bot on the given network, optionally joining
some channels
"""
conn = IRCConnection(host, port, nick, ssl)
bot_instance = bot_class(conn)
while 1:
if not conn.connect():
... | [
"\\",
"Convenience",
"function",
"to",
"start",
"a",
"bot",
"on",
"the",
"given",
"network",
"optionally",
"joining",
"some",
"channels"
] | coleifer/irc | python | https://github.com/coleifer/irc/blob/f9d2bd6369aafe6cb0916c9406270ca8ecea2080/irc.py#L329-L346 | [
"def",
"run_bot",
"(",
"bot_class",
",",
"host",
",",
"port",
",",
"nick",
",",
"channels",
"=",
"None",
",",
"ssl",
"=",
"None",
")",
":",
"conn",
"=",
"IRCConnection",
"(",
"host",
",",
"port",
",",
"nick",
",",
"ssl",
")",
"bot_instance",
"=",
"... | f9d2bd6369aafe6cb0916c9406270ca8ecea2080 |
test | IRCConnection.send | \
Send raw data over the wire if connection is registered. Otherewise,
save the data to an output buffer for transmission later on.
If the force flag is true, always send data, regardless of
registration status. | irc.py | def send(self, data, force=False):
"""\
Send raw data over the wire if connection is registered. Otherewise,
save the data to an output buffer for transmission later on.
If the force flag is true, always send data, regardless of
registration status.
"""
if self._r... | def send(self, data, force=False):
"""\
Send raw data over the wire if connection is registered. Otherewise,
save the data to an output buffer for transmission later on.
If the force flag is true, always send data, regardless of
registration status.
"""
if self._r... | [
"\\",
"Send",
"raw",
"data",
"over",
"the",
"wire",
"if",
"connection",
"is",
"registered",
".",
"Otherewise",
"save",
"the",
"data",
"to",
"an",
"output",
"buffer",
"for",
"transmission",
"later",
"on",
".",
"If",
"the",
"force",
"flag",
"is",
"true",
"... | coleifer/irc | python | https://github.com/coleifer/irc/blob/f9d2bd6369aafe6cb0916c9406270ca8ecea2080/irc.py#L74-L85 | [
"def",
"send",
"(",
"self",
",",
"data",
",",
"force",
"=",
"False",
")",
":",
"if",
"self",
".",
"_registered",
"or",
"force",
":",
"self",
".",
"_sock_file",
".",
"write",
"(",
"'%s\\r\\n'",
"%",
"data",
")",
"self",
".",
"_sock_file",
".",
"flush"... | f9d2bd6369aafe6cb0916c9406270ca8ecea2080 |
test | IRCConnection.connect | \
Connect to the IRC server using the nickname | irc.py | def connect(self):
"""\
Connect to the IRC server using the nickname
"""
self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if self.use_ssl:
self._sock = ssl.wrap_socket(self._sock)
try:
self._sock.connect((self.server, self.port))
... | def connect(self):
"""\
Connect to the IRC server using the nickname
"""
self._sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
if self.use_ssl:
self._sock = ssl.wrap_socket(self._sock)
try:
self._sock.connect((self.server, self.port))
... | [
"\\",
"Connect",
"to",
"the",
"IRC",
"server",
"using",
"the",
"nickname"
] | coleifer/irc | python | https://github.com/coleifer/irc/blob/f9d2bd6369aafe6cb0916c9406270ca8ecea2080/irc.py#L87-L105 | [
"def",
"connect",
"(",
"self",
")",
":",
"self",
".",
"_sock",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
")",
"if",
"self",
".",
"use_ssl",
":",
"self",
".",
"_sock",
"=",
"ssl",
".",
"wrap_socket... | f9d2bd6369aafe6cb0916c9406270ca8ecea2080 |
test | IRCConnection.respond | \
Multipurpose method for sending responses to channel or via message to
a single user | irc.py | def respond(self, message, channel=None, nick=None):
"""\
Multipurpose method for sending responses to channel or via message to
a single user
"""
if channel:
if not channel.startswith('#'):
channel = '#%s' % channel
self.send('PRIVMSG %s :... | def respond(self, message, channel=None, nick=None):
"""\
Multipurpose method for sending responses to channel or via message to
a single user
"""
if channel:
if not channel.startswith('#'):
channel = '#%s' % channel
self.send('PRIVMSG %s :... | [
"\\",
"Multipurpose",
"method",
"for",
"sending",
"responses",
"to",
"channel",
"or",
"via",
"message",
"to",
"a",
"single",
"user"
] | coleifer/irc | python | https://github.com/coleifer/irc/blob/f9d2bd6369aafe6cb0916c9406270ca8ecea2080/irc.py#L134-L144 | [
"def",
"respond",
"(",
"self",
",",
"message",
",",
"channel",
"=",
"None",
",",
"nick",
"=",
"None",
")",
":",
"if",
"channel",
":",
"if",
"not",
"channel",
".",
"startswith",
"(",
"'#'",
")",
":",
"channel",
"=",
"'#%s'",
"%",
"channel",
"self",
... | f9d2bd6369aafe6cb0916c9406270ca8ecea2080 |
test | IRCConnection.dispatch_patterns | \
Low-level dispatching of socket data based on regex matching, in general
handles
* In event a nickname is taken, registers under a different one
* Responds to periodic PING messages from server
* Dispatches to registered callbacks when
- any user leaves or enters a... | irc.py | def dispatch_patterns(self):
"""\
Low-level dispatching of socket data based on regex matching, in general
handles
* In event a nickname is taken, registers under a different one
* Responds to periodic PING messages from server
* Dispatches to registered callbacks when
... | def dispatch_patterns(self):
"""\
Low-level dispatching of socket data based on regex matching, in general
handles
* In event a nickname is taken, registers under a different one
* Responds to periodic PING messages from server
* Dispatches to registered callbacks when
... | [
"\\",
"Low",
"-",
"level",
"dispatching",
"of",
"socket",
"data",
"based",
"on",
"regex",
"matching",
"in",
"general",
"handles"
] | coleifer/irc | python | https://github.com/coleifer/irc/blob/f9d2bd6369aafe6cb0916c9406270ca8ecea2080/irc.py#L146-L168 | [
"def",
"dispatch_patterns",
"(",
"self",
")",
":",
"return",
"(",
"(",
"self",
".",
"nick_re",
",",
"self",
".",
"new_nick",
")",
",",
"(",
"self",
".",
"nick_change_re",
",",
"self",
".",
"handle_nick_change",
")",
",",
"(",
"self",
".",
"ping_re",
",... | f9d2bd6369aafe6cb0916c9406270ca8ecea2080 |
test | IRCConnection.new_nick | \
Generates a new nickname based on original nickname followed by a
random number | irc.py | def new_nick(self):
"""\
Generates a new nickname based on original nickname followed by a
random number
"""
old = self.nick
self.nick = '%s_%s' % (self.base_nick, random.randint(1, 1000))
self.logger.warn('Nick %s already taken, trying %s' % (old, self.nick))
... | def new_nick(self):
"""\
Generates a new nickname based on original nickname followed by a
random number
"""
old = self.nick
self.nick = '%s_%s' % (self.base_nick, random.randint(1, 1000))
self.logger.warn('Nick %s already taken, trying %s' % (old, self.nick))
... | [
"\\",
"Generates",
"a",
"new",
"nickname",
"based",
"on",
"original",
"nickname",
"followed",
"by",
"a",
"random",
"number"
] | coleifer/irc | python | https://github.com/coleifer/irc/blob/f9d2bd6369aafe6cb0916c9406270ca8ecea2080/irc.py#L176-L185 | [
"def",
"new_nick",
"(",
"self",
")",
":",
"old",
"=",
"self",
".",
"nick",
"self",
".",
"nick",
"=",
"'%s_%s'",
"%",
"(",
"self",
".",
"base_nick",
",",
"random",
".",
"randint",
"(",
"1",
",",
"1000",
")",
")",
"self",
".",
"logger",
".",
"warn"... | f9d2bd6369aafe6cb0916c9406270ca8ecea2080 |
test | IRCConnection.handle_ping | \
Respond to periodic PING messages from server | irc.py | def handle_ping(self, payload):
"""\
Respond to periodic PING messages from server
"""
self.logger.info('server ping: %s' % payload)
self.send('PONG %s' % payload, True) | def handle_ping(self, payload):
"""\
Respond to periodic PING messages from server
"""
self.logger.info('server ping: %s' % payload)
self.send('PONG %s' % payload, True) | [
"\\",
"Respond",
"to",
"periodic",
"PING",
"messages",
"from",
"server"
] | coleifer/irc | python | https://github.com/coleifer/irc/blob/f9d2bd6369aafe6cb0916c9406270ca8ecea2080/irc.py#L192-L197 | [
"def",
"handle_ping",
"(",
"self",
",",
"payload",
")",
":",
"self",
".",
"logger",
".",
"info",
"(",
"'server ping: %s'",
"%",
"payload",
")",
"self",
".",
"send",
"(",
"'PONG %s'",
"%",
"payload",
",",
"True",
")"
] | f9d2bd6369aafe6cb0916c9406270ca8ecea2080 |
test | IRCConnection.handle_registered | \
When the connection to the server is registered, send all pending
data. | irc.py | def handle_registered(self, server):
"""\
When the connection to the server is registered, send all pending
data.
"""
if not self._registered:
self.logger.info('Registered')
self._registered = True
for data in self._out_buffer:
... | def handle_registered(self, server):
"""\
When the connection to the server is registered, send all pending
data.
"""
if not self._registered:
self.logger.info('Registered')
self._registered = True
for data in self._out_buffer:
... | [
"\\",
"When",
"the",
"connection",
"to",
"the",
"server",
"is",
"registered",
"send",
"all",
"pending",
"data",
"."
] | coleifer/irc | python | https://github.com/coleifer/irc/blob/f9d2bd6369aafe6cb0916c9406270ca8ecea2080/irc.py#L199-L209 | [
"def",
"handle_registered",
"(",
"self",
",",
"server",
")",
":",
"if",
"not",
"self",
".",
"_registered",
":",
"self",
".",
"logger",
".",
"info",
"(",
"'Registered'",
")",
"self",
".",
"_registered",
"=",
"True",
"for",
"data",
"in",
"self",
".",
"_o... | f9d2bd6369aafe6cb0916c9406270ca8ecea2080 |
test | IRCConnection.enter_event_loop | \
Main loop of the IRCConnection - reads from the socket and dispatches
based on regex matching | irc.py | def enter_event_loop(self):
"""\
Main loop of the IRCConnection - reads from the socket and dispatches
based on regex matching
"""
patterns = self.dispatch_patterns()
self.logger.debug('entering receive loop')
while 1:
try:
data = self... | def enter_event_loop(self):
"""\
Main loop of the IRCConnection - reads from the socket and dispatches
based on regex matching
"""
patterns = self.dispatch_patterns()
self.logger.debug('entering receive loop')
while 1:
try:
data = self... | [
"\\",
"Main",
"loop",
"of",
"the",
"IRCConnection",
"-",
"reads",
"from",
"the",
"socket",
"and",
"dispatches",
"based",
"on",
"regex",
"matching"
] | coleifer/irc | python | https://github.com/coleifer/irc/blob/f9d2bd6369aafe6cb0916c9406270ca8ecea2080/irc.py#L246-L270 | [
"def",
"enter_event_loop",
"(",
"self",
")",
":",
"patterns",
"=",
"self",
".",
"dispatch_patterns",
"(",
")",
"self",
".",
"logger",
".",
"debug",
"(",
"'entering receive loop'",
")",
"while",
"1",
":",
"try",
":",
"data",
"=",
"self",
".",
"_sock_file",
... | f9d2bd6369aafe6cb0916c9406270ca8ecea2080 |
test | IRCBot.register_callbacks | \
Hook for registering callbacks with connection -- handled by __init__() | irc.py | def register_callbacks(self):
"""\
Hook for registering callbacks with connection -- handled by __init__()
"""
self.conn.register_callbacks((
(re.compile(pattern), callback) \
for pattern, callback in self.command_patterns()
)) | def register_callbacks(self):
"""\
Hook for registering callbacks with connection -- handled by __init__()
"""
self.conn.register_callbacks((
(re.compile(pattern), callback) \
for pattern, callback in self.command_patterns()
)) | [
"\\",
"Hook",
"for",
"registering",
"callbacks",
"with",
"connection",
"--",
"handled",
"by",
"__init__",
"()"
] | coleifer/irc | python | https://github.com/coleifer/irc/blob/f9d2bd6369aafe6cb0916c9406270ca8ecea2080/irc.py#L284-L291 | [
"def",
"register_callbacks",
"(",
"self",
")",
":",
"self",
".",
"conn",
".",
"register_callbacks",
"(",
"(",
"(",
"re",
".",
"compile",
"(",
"pattern",
")",
",",
"callback",
")",
"for",
"pattern",
",",
"callback",
"in",
"self",
".",
"command_patterns",
... | f9d2bd6369aafe6cb0916c9406270ca8ecea2080 |
test | IRCBot.respond | \
Wraps the connection object's respond() method | irc.py | def respond(self, message, channel=None, nick=None):
"""\
Wraps the connection object's respond() method
"""
self.conn.respond(message, channel, nick) | def respond(self, message, channel=None, nick=None):
"""\
Wraps the connection object's respond() method
"""
self.conn.respond(message, channel, nick) | [
"\\",
"Wraps",
"the",
"connection",
"object",
"s",
"respond",
"()",
"method"
] | coleifer/irc | python | https://github.com/coleifer/irc/blob/f9d2bd6369aafe6cb0916c9406270ca8ecea2080/irc.py#L322-L326 | [
"def",
"respond",
"(",
"self",
",",
"message",
",",
"channel",
"=",
"None",
",",
"nick",
"=",
"None",
")",
":",
"self",
".",
"conn",
".",
"respond",
"(",
"message",
",",
"channel",
",",
"nick",
")"
] | f9d2bd6369aafe6cb0916c9406270ca8ecea2080 |
test | BaseWorkerBot.register_with_boss | \
Register the worker with the boss | botnet/worker.py | def register_with_boss(self):
"""\
Register the worker with the boss
"""
gevent.sleep(10) # wait for things to connect, etc
while not self.registered.is_set():
self.respond('!register {%s}' % platform.node(), nick=self.boss)
gevent.sleep(30) | def register_with_boss(self):
"""\
Register the worker with the boss
"""
gevent.sleep(10) # wait for things to connect, etc
while not self.registered.is_set():
self.respond('!register {%s}' % platform.node(), nick=self.boss)
gevent.sleep(30) | [
"\\",
"Register",
"the",
"worker",
"with",
"the",
"boss"
] | coleifer/irc | python | https://github.com/coleifer/irc/blob/f9d2bd6369aafe6cb0916c9406270ca8ecea2080/botnet/worker.py#L64-L72 | [
"def",
"register_with_boss",
"(",
"self",
")",
":",
"gevent",
".",
"sleep",
"(",
"10",
")",
"# wait for things to connect, etc",
"while",
"not",
"self",
".",
"registered",
".",
"is_set",
"(",
")",
":",
"self",
".",
"respond",
"(",
"'!register {%s}'",
"%",
"p... | f9d2bd6369aafe6cb0916c9406270ca8ecea2080 |
test | BaseWorkerBot.task_runner | \
Run tasks in a greenlet, pulling from the workers' task queue and
reporting results to the command channel | botnet/worker.py | def task_runner(self):
"""\
Run tasks in a greenlet, pulling from the workers' task queue and
reporting results to the command channel
"""
while 1:
(task_id, command) = self.task_queue.get()
for pattern, callback in self.task_patterns:
... | def task_runner(self):
"""\
Run tasks in a greenlet, pulling from the workers' task queue and
reporting results to the command channel
"""
while 1:
(task_id, command) = self.task_queue.get()
for pattern, callback in self.task_patterns:
... | [
"\\",
"Run",
"tasks",
"in",
"a",
"greenlet",
"pulling",
"from",
"the",
"workers",
"task",
"queue",
"and",
"reporting",
"results",
"to",
"the",
"command",
"channel"
] | coleifer/irc | python | https://github.com/coleifer/irc/blob/f9d2bd6369aafe6cb0916c9406270ca8ecea2080/botnet/worker.py#L74-L97 | [
"def",
"task_runner",
"(",
"self",
")",
":",
"while",
"1",
":",
"(",
"task_id",
",",
"command",
")",
"=",
"self",
".",
"task_queue",
".",
"get",
"(",
")",
"for",
"pattern",
",",
"callback",
"in",
"self",
".",
"task_patterns",
":",
"match",
"=",
"re",... | f9d2bd6369aafe6cb0916c9406270ca8ecea2080 |
test | BaseWorkerBot.require_boss | \
Decorator to ensure that commands only can come from the boss | botnet/worker.py | def require_boss(self, callback):
"""\
Decorator to ensure that commands only can come from the boss
"""
def inner(nick, message, channel, *args, **kwargs):
if nick != self.boss:
return
return callback(nick, message, channel, *args, **... | def require_boss(self, callback):
"""\
Decorator to ensure that commands only can come from the boss
"""
def inner(nick, message, channel, *args, **kwargs):
if nick != self.boss:
return
return callback(nick, message, channel, *args, **... | [
"\\",
"Decorator",
"to",
"ensure",
"that",
"commands",
"only",
"can",
"come",
"from",
"the",
"boss"
] | coleifer/irc | python | https://github.com/coleifer/irc/blob/f9d2bd6369aafe6cb0916c9406270ca8ecea2080/botnet/worker.py#L99-L108 | [
"def",
"require_boss",
"(",
"self",
",",
"callback",
")",
":",
"def",
"inner",
"(",
"nick",
",",
"message",
",",
"channel",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"nick",
"!=",
"self",
".",
"boss",
":",
"return",
"return",
"call... | f9d2bd6369aafe6cb0916c9406270ca8ecea2080 |
test | BaseWorkerBot.command_patterns | \
Actual messages listened for by the worker bot - note that worker-execute
actually dispatches again by adding the command to the task queue,
from which it is pulled then matched against self.task_patterns | botnet/worker.py | def command_patterns(self):
"""\
Actual messages listened for by the worker bot - note that worker-execute
actually dispatches again by adding the command to the task queue,
from which it is pulled then matched against self.task_patterns
"""
return (
('!regist... | def command_patterns(self):
"""\
Actual messages listened for by the worker bot - note that worker-execute
actually dispatches again by adding the command to the task queue,
from which it is pulled then matched against self.task_patterns
"""
return (
('!regist... | [
"\\",
"Actual",
"messages",
"listened",
"for",
"by",
"the",
"worker",
"bot",
"-",
"note",
"that",
"worker",
"-",
"execute",
"actually",
"dispatches",
"again",
"by",
"adding",
"the",
"command",
"to",
"the",
"task",
"queue",
"from",
"which",
"it",
"is",
"pul... | coleifer/irc | python | https://github.com/coleifer/irc/blob/f9d2bd6369aafe6cb0916c9406270ca8ecea2080/botnet/worker.py#L110-L121 | [
"def",
"command_patterns",
"(",
"self",
")",
":",
"return",
"(",
"(",
"'!register-success (?P<cmd_channel>.+)'",
",",
"self",
".",
"require_boss",
"(",
"self",
".",
"register_success",
")",
")",
",",
"(",
"'!worker-execute (?:\\((?P<workers>.+?)\\) )?(?P<task_id>\\d+):(?P... | f9d2bd6369aafe6cb0916c9406270ca8ecea2080 |
test | BaseWorkerBot.register_success | \
Received registration acknowledgement from the BotnetBot, as well as the
name of the command channel, so join up and indicate that registration
succeeded | botnet/worker.py | def register_success(self, nick, message, channel, cmd_channel):
"""\
Received registration acknowledgement from the BotnetBot, as well as the
name of the command channel, so join up and indicate that registration
succeeded
"""
# the boss will tell what channel to join
... | def register_success(self, nick, message, channel, cmd_channel):
"""\
Received registration acknowledgement from the BotnetBot, as well as the
name of the command channel, so join up and indicate that registration
succeeded
"""
# the boss will tell what channel to join
... | [
"\\",
"Received",
"registration",
"acknowledgement",
"from",
"the",
"BotnetBot",
"as",
"well",
"as",
"the",
"name",
"of",
"the",
"command",
"channel",
"so",
"join",
"up",
"and",
"indicate",
"that",
"registration",
"succeeded"
] | coleifer/irc | python | https://github.com/coleifer/irc/blob/f9d2bd6369aafe6cb0916c9406270ca8ecea2080/botnet/worker.py#L123-L134 | [
"def",
"register_success",
"(",
"self",
",",
"nick",
",",
"message",
",",
"channel",
",",
"cmd_channel",
")",
":",
"# the boss will tell what channel to join",
"self",
".",
"channel",
"=",
"cmd_channel",
"self",
".",
"conn",
".",
"join",
"(",
"self",
".",
"cha... | f9d2bd6369aafe6cb0916c9406270ca8ecea2080 |
test | BaseWorkerBot.worker_execute | \
Work on a task from the BotnetBot | botnet/worker.py | def worker_execute(self, nick, message, channel, task_id, command, workers=None):
"""\
Work on a task from the BotnetBot
"""
if workers:
nicks = workers.split(',')
do_task = self.conn.nick in nicks
else:
do_task = True
if do_ta... | def worker_execute(self, nick, message, channel, task_id, command, workers=None):
"""\
Work on a task from the BotnetBot
"""
if workers:
nicks = workers.split(',')
do_task = self.conn.nick in nicks
else:
do_task = True
if do_ta... | [
"\\",
"Work",
"on",
"a",
"task",
"from",
"the",
"BotnetBot"
] | coleifer/irc | python | https://github.com/coleifer/irc/blob/f9d2bd6369aafe6cb0916c9406270ca8ecea2080/botnet/worker.py#L136-L148 | [
"def",
"worker_execute",
"(",
"self",
",",
"nick",
",",
"message",
",",
"channel",
",",
"task_id",
",",
"command",
",",
"workers",
"=",
"None",
")",
":",
"if",
"workers",
":",
"nicks",
"=",
"workers",
".",
"split",
"(",
"','",
")",
"do_task",
"=",
"s... | f9d2bd6369aafe6cb0916c9406270ca8ecea2080 |
test | Task.add | \
Indicate that the worker with given nick is performing this task | botnet/boss.py | def add(self, nick):
"""\
Indicate that the worker with given nick is performing this task
"""
self.data[nick] = ''
self.workers.add(nick) | def add(self, nick):
"""\
Indicate that the worker with given nick is performing this task
"""
self.data[nick] = ''
self.workers.add(nick) | [
"\\",
"Indicate",
"that",
"the",
"worker",
"with",
"given",
"nick",
"is",
"performing",
"this",
"task"
] | coleifer/irc | python | https://github.com/coleifer/irc/blob/f9d2bd6369aafe6cb0916c9406270ca8ecea2080/botnet/boss.py#L51-L56 | [
"def",
"add",
"(",
"self",
",",
"nick",
")",
":",
"self",
".",
"data",
"[",
"nick",
"]",
"=",
"''",
"self",
".",
"workers",
".",
"add",
"(",
"nick",
")"
] | f9d2bd6369aafe6cb0916c9406270ca8ecea2080 |
test | EmailVerifyUserMethodsMixin.send_validation_email | Send a validation email to the user's email address. | user_management/models/mixins.py | def send_validation_email(self):
"""Send a validation email to the user's email address."""
if self.email_verified:
raise ValueError(_('Cannot validate already active user.'))
site = Site.objects.get_current()
self.validation_notification(user=self, site=site).notify() | def send_validation_email(self):
"""Send a validation email to the user's email address."""
if self.email_verified:
raise ValueError(_('Cannot validate already active user.'))
site = Site.objects.get_current()
self.validation_notification(user=self, site=site).notify() | [
"Send",
"a",
"validation",
"email",
"to",
"the",
"user",
"s",
"email",
"address",
"."
] | incuna/django-user-management | python | https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/models/mixins.py#L155-L161 | [
"def",
"send_validation_email",
"(",
"self",
")",
":",
"if",
"self",
".",
"email_verified",
":",
"raise",
"ValueError",
"(",
"_",
"(",
"'Cannot validate already active user.'",
")",
")",
"site",
"=",
"Site",
".",
"objects",
".",
"get_current",
"(",
")",
"self"... | 6784e33191d4eff624d2cf2df9ca01db4f23c9c6 |
test | EmailVerifyUserMethodsMixin.send_password_reset | Send a password reset to the user's email address. | user_management/models/mixins.py | def send_password_reset(self):
"""Send a password reset to the user's email address."""
site = Site.objects.get_current()
self.password_reset_notification(user=self, site=site).notify() | def send_password_reset(self):
"""Send a password reset to the user's email address."""
site = Site.objects.get_current()
self.password_reset_notification(user=self, site=site).notify() | [
"Send",
"a",
"password",
"reset",
"to",
"the",
"user",
"s",
"email",
"address",
"."
] | incuna/django-user-management | python | https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/models/mixins.py#L163-L166 | [
"def",
"send_password_reset",
"(",
"self",
")",
":",
"site",
"=",
"Site",
".",
"objects",
".",
"get_current",
"(",
")",
"self",
".",
"password_reset_notification",
"(",
"user",
"=",
"self",
",",
"site",
"=",
"site",
")",
".",
"notify",
"(",
")"
] | 6784e33191d4eff624d2cf2df9ca01db4f23c9c6 |
test | validate_password_strength | Passwords should be tough.
That means they should use:
- mixed case letters,
- numbers,
- (optionally) ascii symbols and spaces.
The (contrversial?) decision to limit the passwords to ASCII only
is for the sake of:
- simplicity (no need to normalise UTF-8 input)
- security (some charac... | user_management/utils/validators.py | def validate_password_strength(value):
"""
Passwords should be tough.
That means they should use:
- mixed case letters,
- numbers,
- (optionally) ascii symbols and spaces.
The (contrversial?) decision to limit the passwords to ASCII only
is for the sake of:
- simplicity (no need to... | def validate_password_strength(value):
"""
Passwords should be tough.
That means they should use:
- mixed case letters,
- numbers,
- (optionally) ascii symbols and spaces.
The (contrversial?) decision to limit the passwords to ASCII only
is for the sake of:
- simplicity (no need to... | [
"Passwords",
"should",
"be",
"tough",
"."
] | incuna/django-user-management | python | https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/utils/validators.py#L23-L54 | [
"def",
"validate_password_strength",
"(",
"value",
")",
":",
"used_chars",
"=",
"set",
"(",
"value",
")",
"good_chars",
"=",
"set",
"(",
"ascii_letters",
"+",
"digits",
"+",
"punctuation",
"+",
"' '",
")",
"required_sets",
"=",
"(",
"ascii_uppercase",
",",
"... | 6784e33191d4eff624d2cf2df9ca01db4f23c9c6 |
test | VerifyAccountViewMixin.verify_token | Use `token` to allow one-time access to a view.
Set the user as a class attribute or raise an `InvalidExpiredToken`.
Token expiry can be set in `settings` with `VERIFY_ACCOUNT_EXPIRY` and is
set in seconds. | user_management/utils/views.py | def verify_token(self, request, *args, **kwargs):
"""
Use `token` to allow one-time access to a view.
Set the user as a class attribute or raise an `InvalidExpiredToken`.
Token expiry can be set in `settings` with `VERIFY_ACCOUNT_EXPIRY` and is
set in seconds.
"""
... | def verify_token(self, request, *args, **kwargs):
"""
Use `token` to allow one-time access to a view.
Set the user as a class attribute or raise an `InvalidExpiredToken`.
Token expiry can be set in `settings` with `VERIFY_ACCOUNT_EXPIRY` and is
set in seconds.
"""
... | [
"Use",
"token",
"to",
"allow",
"one",
"-",
"time",
"access",
"to",
"a",
"view",
"."
] | incuna/django-user-management | python | https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/utils/views.py#L23-L52 | [
"def",
"verify_token",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"User",
"=",
"get_user_model",
"(",
")",
"try",
":",
"max_age",
"=",
"settings",
".",
"VERIFY_ACCOUNT_EXPIRY",
"except",
"AttributeError",
":",
"max_ag... | 6784e33191d4eff624d2cf2df9ca01db4f23c9c6 |
test | ProfileAvatar.delete | Delete the user's avatar.
We set `user.avatar = None` instead of calling `user.avatar.delete()`
to avoid test errors with `django.inmemorystorage`. | user_management/api/avatar/views.py | def delete(self, request, *args, **kwargs):
"""
Delete the user's avatar.
We set `user.avatar = None` instead of calling `user.avatar.delete()`
to avoid test errors with `django.inmemorystorage`.
"""
user = self.get_object()
user.avatar = None
user.save()... | def delete(self, request, *args, **kwargs):
"""
Delete the user's avatar.
We set `user.avatar = None` instead of calling `user.avatar.delete()`
to avoid test errors with `django.inmemorystorage`.
"""
user = self.get_object()
user.avatar = None
user.save()... | [
"Delete",
"the",
"user",
"s",
"avatar",
"."
] | incuna/django-user-management | python | https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/api/avatar/views.py#L63-L73 | [
"def",
"delete",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"user",
"=",
"self",
".",
"get_object",
"(",
")",
"user",
".",
"avatar",
"=",
"None",
"user",
".",
"save",
"(",
")",
"return",
"response",
".",
"Re... | 6784e33191d4eff624d2cf2df9ca01db4f23c9c6 |
test | PostRequestThrottleMixin.allow_request | Throttle POST requests only. | user_management/api/throttling.py | def allow_request(self, request, view):
"""
Throttle POST requests only.
"""
if request.method != 'POST':
return True
return super(PostRequestThrottleMixin, self).allow_request(request, view) | def allow_request(self, request, view):
"""
Throttle POST requests only.
"""
if request.method != 'POST':
return True
return super(PostRequestThrottleMixin, self).allow_request(request, view) | [
"Throttle",
"POST",
"requests",
"only",
"."
] | incuna/django-user-management | python | https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/api/throttling.py#L13-L20 | [
"def",
"allow_request",
"(",
"self",
",",
"request",
",",
"view",
")",
":",
"if",
"request",
".",
"method",
"!=",
"'POST'",
":",
"return",
"True",
"return",
"super",
"(",
"PostRequestThrottleMixin",
",",
"self",
")",
".",
"allow_request",
"(",
"request",
"... | 6784e33191d4eff624d2cf2df9ca01db4f23c9c6 |
test | SwarmSpawner.executor | single global executor | cassinyspawner/swarmspawner.py | def executor(self, max_workers=1):
"""single global executor"""
cls = self.__class__
if cls._executor is None:
cls._executor = ThreadPoolExecutor(max_workers)
return cls._executor | def executor(self, max_workers=1):
"""single global executor"""
cls = self.__class__
if cls._executor is None:
cls._executor = ThreadPoolExecutor(max_workers)
return cls._executor | [
"single",
"global",
"executor"
] | cassinyio/SwarmSpawner | python | https://github.com/cassinyio/SwarmSpawner/blob/3c39134ef7e02e2afc5d18da7d18d2c69421ed08/cassinyspawner/swarmspawner.py#L42-L47 | [
"def",
"executor",
"(",
"self",
",",
"max_workers",
"=",
"1",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"if",
"cls",
".",
"_executor",
"is",
"None",
":",
"cls",
".",
"_executor",
"=",
"ThreadPoolExecutor",
"(",
"max_workers",
")",
"return",
"cls",
... | 3c39134ef7e02e2afc5d18da7d18d2c69421ed08 |
test | SwarmSpawner.client | single global client instance | cassinyspawner/swarmspawner.py | def client(self):
"""single global client instance"""
cls = self.__class__
if cls._client is None:
kwargs = {}
if self.tls_config:
kwargs['tls'] = docker.tls.TLSConfig(**self.tls_config)
kwargs.update(kwargs_from_env())
client = do... | def client(self):
"""single global client instance"""
cls = self.__class__
if cls._client is None:
kwargs = {}
if self.tls_config:
kwargs['tls'] = docker.tls.TLSConfig(**self.tls_config)
kwargs.update(kwargs_from_env())
client = do... | [
"single",
"global",
"client",
"instance"
] | cassinyio/SwarmSpawner | python | https://github.com/cassinyio/SwarmSpawner/blob/3c39134ef7e02e2afc5d18da7d18d2c69421ed08/cassinyspawner/swarmspawner.py#L52-L64 | [
"def",
"client",
"(",
"self",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"if",
"cls",
".",
"_client",
"is",
"None",
":",
"kwargs",
"=",
"{",
"}",
"if",
"self",
".",
"tls_config",
":",
"kwargs",
"[",
"'tls'",
"]",
"=",
"docker",
".",
"tls",
"... | 3c39134ef7e02e2afc5d18da7d18d2c69421ed08 |
test | SwarmSpawner.tls_client | A tuple consisting of the TLS client certificate and key if they
have been provided, otherwise None. | cassinyspawner/swarmspawner.py | def tls_client(self):
"""A tuple consisting of the TLS client certificate and key if they
have been provided, otherwise None.
"""
if self.tls_cert and self.tls_key:
return (self.tls_cert, self.tls_key)
return None | def tls_client(self):
"""A tuple consisting of the TLS client certificate and key if they
have been provided, otherwise None.
"""
if self.tls_cert and self.tls_key:
return (self.tls_cert, self.tls_key)
return None | [
"A",
"tuple",
"consisting",
"of",
"the",
"TLS",
"client",
"certificate",
"and",
"key",
"if",
"they",
"have",
"been",
"provided",
"otherwise",
"None",
"."
] | cassinyio/SwarmSpawner | python | https://github.com/cassinyio/SwarmSpawner/blob/3c39134ef7e02e2afc5d18da7d18d2c69421ed08/cassinyspawner/swarmspawner.py#L112-L119 | [
"def",
"tls_client",
"(",
"self",
")",
":",
"if",
"self",
".",
"tls_cert",
"and",
"self",
".",
"tls_key",
":",
"return",
"(",
"self",
".",
"tls_cert",
",",
"self",
".",
"tls_key",
")",
"return",
"None"
] | 3c39134ef7e02e2afc5d18da7d18d2c69421ed08 |
test | SwarmSpawner.service_name | Service name inside the Docker Swarm
service_suffix should be a numerical value unique for user
{service_prefix}-{service_owner}-{service_suffix} | cassinyspawner/swarmspawner.py | def service_name(self):
"""
Service name inside the Docker Swarm
service_suffix should be a numerical value unique for user
{service_prefix}-{service_owner}-{service_suffix}
"""
if hasattr(self, "server_name") and self.server_name:
server_name = self.server_n... | def service_name(self):
"""
Service name inside the Docker Swarm
service_suffix should be a numerical value unique for user
{service_prefix}-{service_owner}-{service_suffix}
"""
if hasattr(self, "server_name") and self.server_name:
server_name = self.server_n... | [
"Service",
"name",
"inside",
"the",
"Docker",
"Swarm"
] | cassinyio/SwarmSpawner | python | https://github.com/cassinyio/SwarmSpawner/blob/3c39134ef7e02e2afc5d18da7d18d2c69421ed08/cassinyspawner/swarmspawner.py#L132-L147 | [
"def",
"service_name",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"\"server_name\"",
")",
"and",
"self",
".",
"server_name",
":",
"server_name",
"=",
"self",
".",
"server_name",
"else",
":",
"server_name",
"=",
"1",
"return",
"\"{}-{}-{}\"",
... | 3c39134ef7e02e2afc5d18da7d18d2c69421ed08 |
test | SwarmSpawner._docker | wrapper for calling docker methods
to be passed to ThreadPoolExecutor | cassinyspawner/swarmspawner.py | def _docker(self, method, *args, **kwargs):
"""wrapper for calling docker methods
to be passed to ThreadPoolExecutor
"""
m = getattr(self.client, method)
return m(*args, **kwargs) | def _docker(self, method, *args, **kwargs):
"""wrapper for calling docker methods
to be passed to ThreadPoolExecutor
"""
m = getattr(self.client, method)
return m(*args, **kwargs) | [
"wrapper",
"for",
"calling",
"docker",
"methods"
] | cassinyio/SwarmSpawner | python | https://github.com/cassinyio/SwarmSpawner/blob/3c39134ef7e02e2afc5d18da7d18d2c69421ed08/cassinyspawner/swarmspawner.py#L189-L195 | [
"def",
"_docker",
"(",
"self",
",",
"method",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"m",
"=",
"getattr",
"(",
"self",
".",
"client",
",",
"method",
")",
"return",
"m",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | 3c39134ef7e02e2afc5d18da7d18d2c69421ed08 |
test | SwarmSpawner.docker | Call a docker method in a background thread
returns a Future | cassinyspawner/swarmspawner.py | def docker(self, method, *args, **kwargs):
"""Call a docker method in a background thread
returns a Future
"""
return self.executor.submit(self._docker, method, *args, **kwargs) | def docker(self, method, *args, **kwargs):
"""Call a docker method in a background thread
returns a Future
"""
return self.executor.submit(self._docker, method, *args, **kwargs) | [
"Call",
"a",
"docker",
"method",
"in",
"a",
"background",
"thread"
] | cassinyio/SwarmSpawner | python | https://github.com/cassinyio/SwarmSpawner/blob/3c39134ef7e02e2afc5d18da7d18d2c69421ed08/cassinyspawner/swarmspawner.py#L197-L202 | [
"def",
"docker",
"(",
"self",
",",
"method",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"executor",
".",
"submit",
"(",
"self",
".",
"_docker",
",",
"method",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | 3c39134ef7e02e2afc5d18da7d18d2c69421ed08 |
test | SwarmSpawner.poll | Check for a task state like `docker service ps id` | cassinyspawner/swarmspawner.py | def poll(self):
"""Check for a task state like `docker service ps id`"""
service = yield self.get_service()
if not service:
self.log.warn("Docker service not found")
return 0
task_filter = {'service': service['Spec']['Name']}
tasks = yield self.docker(
... | def poll(self):
"""Check for a task state like `docker service ps id`"""
service = yield self.get_service()
if not service:
self.log.warn("Docker service not found")
return 0
task_filter = {'service': service['Spec']['Name']}
tasks = yield self.docker(
... | [
"Check",
"for",
"a",
"task",
"state",
"like",
"docker",
"service",
"ps",
"id"
] | cassinyio/SwarmSpawner | python | https://github.com/cassinyio/SwarmSpawner/blob/3c39134ef7e02e2afc5d18da7d18d2c69421ed08/cassinyspawner/swarmspawner.py#L205-L234 | [
"def",
"poll",
"(",
"self",
")",
":",
"service",
"=",
"yield",
"self",
".",
"get_service",
"(",
")",
"if",
"not",
"service",
":",
"self",
".",
"log",
".",
"warn",
"(",
"\"Docker service not found\"",
")",
"return",
"0",
"task_filter",
"=",
"{",
"'service... | 3c39134ef7e02e2afc5d18da7d18d2c69421ed08 |
test | SwarmSpawner.start | Start the single-user server in a docker service.
You can specify the params for the service through jupyterhub_config.py
or using the user_options | cassinyspawner/swarmspawner.py | def start(self):
"""Start the single-user server in a docker service.
You can specify the params for the service through jupyterhub_config.py
or using the user_options
"""
# https://github.com/jupyterhub/jupyterhub/blob/master/jupyterhub/user.py#L202
# By default jupyter... | def start(self):
"""Start the single-user server in a docker service.
You can specify the params for the service through jupyterhub_config.py
or using the user_options
"""
# https://github.com/jupyterhub/jupyterhub/blob/master/jupyterhub/user.py#L202
# By default jupyter... | [
"Start",
"the",
"single",
"-",
"user",
"server",
"in",
"a",
"docker",
"service",
".",
"You",
"can",
"specify",
"the",
"params",
"for",
"the",
"service",
"through",
"jupyterhub_config",
".",
"py",
"or",
"using",
"the",
"user_options"
] | cassinyio/SwarmSpawner | python | https://github.com/cassinyio/SwarmSpawner/blob/3c39134ef7e02e2afc5d18da7d18d2c69421ed08/cassinyspawner/swarmspawner.py#L260-L370 | [
"def",
"start",
"(",
"self",
")",
":",
"# https://github.com/jupyterhub/jupyterhub/blob/master/jupyterhub/user.py#L202",
"# By default jupyterhub calls the spawner passing user_options",
"if",
"self",
".",
"use_user_options",
":",
"user_options",
"=",
"self",
".",
"user_options",
... | 3c39134ef7e02e2afc5d18da7d18d2c69421ed08 |
test | SwarmSpawner.stop | Stop and remove the service
Consider using stop/start when Docker adds support | cassinyspawner/swarmspawner.py | def stop(self, now=False):
"""Stop and remove the service
Consider using stop/start when Docker adds support
"""
self.log.info(
"Stopping and removing Docker service %s (id: %s)",
self.service_name, self.service_id[:7])
yield self.docker('remove_service',... | def stop(self, now=False):
"""Stop and remove the service
Consider using stop/start when Docker adds support
"""
self.log.info(
"Stopping and removing Docker service %s (id: %s)",
self.service_name, self.service_id[:7])
yield self.docker('remove_service',... | [
"Stop",
"and",
"remove",
"the",
"service"
] | cassinyio/SwarmSpawner | python | https://github.com/cassinyio/SwarmSpawner/blob/3c39134ef7e02e2afc5d18da7d18d2c69421ed08/cassinyspawner/swarmspawner.py#L373-L386 | [
"def",
"stop",
"(",
"self",
",",
"now",
"=",
"False",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"Stopping and removing Docker service %s (id: %s)\"",
",",
"self",
".",
"service_name",
",",
"self",
".",
"service_id",
"[",
":",
"7",
"]",
")",
"yield"... | 3c39134ef7e02e2afc5d18da7d18d2c69421ed08 |
test | UniqueEmailValidator.filter_queryset | Check lower-cased email is unique. | user_management/api/serializers.py | def filter_queryset(self, value, queryset):
"""Check lower-cased email is unique."""
return super(UniqueEmailValidator, self).filter_queryset(
value.lower(),
queryset,
) | def filter_queryset(self, value, queryset):
"""Check lower-cased email is unique."""
return super(UniqueEmailValidator, self).filter_queryset(
value.lower(),
queryset,
) | [
"Check",
"lower",
"-",
"cased",
"email",
"is",
"unique",
"."
] | incuna/django-user-management | python | https://github.com/incuna/django-user-management/blob/6784e33191d4eff624d2cf2df9ca01db4f23c9c6/user_management/api/serializers.py#L12-L17 | [
"def",
"filter_queryset",
"(",
"self",
",",
"value",
",",
"queryset",
")",
":",
"return",
"super",
"(",
"UniqueEmailValidator",
",",
"self",
")",
".",
"filter_queryset",
"(",
"value",
".",
"lower",
"(",
")",
",",
"queryset",
",",
")"
] | 6784e33191d4eff624d2cf2df9ca01db4f23c9c6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.