repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
Galarzaa90/tibia.py
tibiapy/guild.py
ListedGuild.get_world_list_url_tibiadata
def get_world_list_url_tibiadata(cls, world): """Gets the TibiaData.com URL for the guild list of a specific world. Parameters ---------- world: :class:`str` The name of the world. Returns ------- :class:`str` The URL to the guild's page....
python
def get_world_list_url_tibiadata(cls, world): """Gets the TibiaData.com URL for the guild list of a specific world. Parameters ---------- world: :class:`str` The name of the world. Returns ------- :class:`str` The URL to the guild's page....
[ "def", "get_world_list_url_tibiadata", "(", "cls", ",", "world", ")", ":", "return", "GUILD_LIST_URL_TIBIADATA", "%", "urllib", ".", "parse", ".", "quote", "(", "world", ".", "title", "(", ")", ".", "encode", "(", "'iso-8859-1'", ")", ")" ]
Gets the TibiaData.com URL for the guild list of a specific world. Parameters ---------- world: :class:`str` The name of the world. Returns ------- :class:`str` The URL to the guild's page.
[ "Gets", "the", "TibiaData", ".", "com", "URL", "for", "the", "guild", "list", "of", "a", "specific", "world", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/guild.py#L459-L472
Galarzaa90/tibia.py
tibiapy/guild.py
ListedGuild.list_from_content
def list_from_content(cls, content): """ Gets a list of guilds from the HTML content of the world guilds' page. Parameters ---------- content: :class:`str` The HTML content of the page. Returns ------- :class:`list` of :class:`ListedGuild` ...
python
def list_from_content(cls, content): """ Gets a list of guilds from the HTML content of the world guilds' page. Parameters ---------- content: :class:`str` The HTML content of the page. Returns ------- :class:`list` of :class:`ListedGuild` ...
[ "def", "list_from_content", "(", "cls", ",", "content", ")", ":", "parsed_content", "=", "parse_tibiacom_content", "(", "content", ")", "selected_world", "=", "parsed_content", ".", "find", "(", "'option'", ",", "selected", "=", "True", ")", "try", ":", "if", ...
Gets a list of guilds from the HTML content of the world guilds' page. Parameters ---------- content: :class:`str` The HTML content of the page. Returns ------- :class:`list` of :class:`ListedGuild` List of guilds in the current world. ``None`` i...
[ "Gets", "a", "list", "of", "guilds", "from", "the", "HTML", "content", "of", "the", "world", "guilds", "page", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/guild.py#L475-L520
Galarzaa90/tibia.py
tibiapy/guild.py
ListedGuild.list_from_tibiadata
def list_from_tibiadata(cls, content): """Builds a character object from a TibiaData character response. Parameters ---------- content: :class:`str` A string containing the JSON response from TibiaData. Returns ------- :class:`list` of :class:`Listed...
python
def list_from_tibiadata(cls, content): """Builds a character object from a TibiaData character response. Parameters ---------- content: :class:`str` A string containing the JSON response from TibiaData. Returns ------- :class:`list` of :class:`Listed...
[ "def", "list_from_tibiadata", "(", "cls", ",", "content", ")", ":", "json_content", "=", "parse_json", "(", "content", ")", "try", ":", "guilds_obj", "=", "json_content", "[", "\"guilds\"", "]", "guilds", "=", "[", "]", "for", "guild", "in", "guilds_obj", ...
Builds a character object from a TibiaData character response. Parameters ---------- content: :class:`str` A string containing the JSON response from TibiaData. Returns ------- :class:`list` of :class:`ListedGuild` The list of guilds contained. ...
[ "Builds", "a", "character", "object", "from", "a", "TibiaData", "character", "response", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/guild.py#L523-L553
tetframework/Tonnikala
tonnikala/ir/generate.py
BaseIRGenerator.merge_text_nodes_on
def merge_text_nodes_on(self, node): """Merges all consecutive non-translatable text nodes into one""" if not isinstance(node, ContainerNode) or not node.children: return new_children = [] text_run = [] for i in node.children: if isinstance(i, Text) and ...
python
def merge_text_nodes_on(self, node): """Merges all consecutive non-translatable text nodes into one""" if not isinstance(node, ContainerNode) or not node.children: return new_children = [] text_run = [] for i in node.children: if isinstance(i, Text) and ...
[ "def", "merge_text_nodes_on", "(", "self", ",", "node", ")", ":", "if", "not", "isinstance", "(", "node", ",", "ContainerNode", ")", "or", "not", "node", ".", "children", ":", "return", "new_children", "=", "[", "]", "text_run", "=", "[", "]", "for", "...
Merges all consecutive non-translatable text nodes into one
[ "Merges", "all", "consecutive", "non", "-", "translatable", "text", "nodes", "into", "one" ]
train
https://github.com/tetframework/Tonnikala/blob/99d168657da1b2372ff898254f80808ea8d1b83f/tonnikala/ir/generate.py#L57-L80
tetframework/Tonnikala
tonnikala/ir/generate.py
BaseIRGenerator.push_state
def push_state(self): """ Push a copy of the topmost state on top of the state stack, returns the new top. """ new = dict(self.states[-1]) self.states.append(new) return self.state
python
def push_state(self): """ Push a copy of the topmost state on top of the state stack, returns the new top. """ new = dict(self.states[-1]) self.states.append(new) return self.state
[ "def", "push_state", "(", "self", ")", ":", "new", "=", "dict", "(", "self", ".", "states", "[", "-", "1", "]", ")", "self", ".", "states", ".", "append", "(", "new", ")", "return", "self", ".", "state" ]
Push a copy of the topmost state on top of the state stack, returns the new top.
[ "Push", "a", "copy", "of", "the", "topmost", "state", "on", "top", "of", "the", "state", "stack", "returns", "the", "new", "top", "." ]
train
https://github.com/tetframework/Tonnikala/blob/99d168657da1b2372ff898254f80808ea8d1b83f/tonnikala/ir/generate.py#L95-L103
tetframework/Tonnikala
tonnikala/ir/generate.py
BaseDOMIRGenerator.enter_node
def enter_node(self, ir_node): """ Enter the given element; keeps track of `cdata`; subclasses may extend by overriding """ this_is_cdata = (isinstance(ir_node, Element) and ir_node.name in self.cdata_elements) self.state['is_cdata'] = bool(self.s...
python
def enter_node(self, ir_node): """ Enter the given element; keeps track of `cdata`; subclasses may extend by overriding """ this_is_cdata = (isinstance(ir_node, Element) and ir_node.name in self.cdata_elements) self.state['is_cdata'] = bool(self.s...
[ "def", "enter_node", "(", "self", ",", "ir_node", ")", ":", "this_is_cdata", "=", "(", "isinstance", "(", "ir_node", ",", "Element", ")", "and", "ir_node", ".", "name", "in", "self", ".", "cdata_elements", ")", "self", ".", "state", "[", "'is_cdata'", "]...
Enter the given element; keeps track of `cdata`; subclasses may extend by overriding
[ "Enter", "the", "given", "element", ";", "keeps", "track", "of", "cdata", ";", "subclasses", "may", "extend", "by", "overriding" ]
train
https://github.com/tetframework/Tonnikala/blob/99d168657da1b2372ff898254f80808ea8d1b83f/tonnikala/ir/generate.py#L162-L169
thanethomson/httpwatcher
httpwatcher/cmdline.py
watch
def watch(static_root, watch_paths=None, on_reload=None, host='localhost', port=5555, server_base_path="/", watcher_interval=1.0, recursive=True, open_browser=True, open_browser_delay=1.0): """Initialises an HttpWatcherServer to watch the given path for changes. Watches until the IO loop is terminated...
python
def watch(static_root, watch_paths=None, on_reload=None, host='localhost', port=5555, server_base_path="/", watcher_interval=1.0, recursive=True, open_browser=True, open_browser_delay=1.0): """Initialises an HttpWatcherServer to watch the given path for changes. Watches until the IO loop is terminated...
[ "def", "watch", "(", "static_root", ",", "watch_paths", "=", "None", ",", "on_reload", "=", "None", ",", "host", "=", "'localhost'", ",", "port", "=", "5555", ",", "server_base_path", "=", "\"/\"", ",", "watcher_interval", "=", "1.0", ",", "recursive", "="...
Initialises an HttpWatcherServer to watch the given path for changes. Watches until the IO loop is terminated, or a keyboard interrupt is intercepted. Args: static_root: The path whose contents are to be served and watched. watch_paths: The paths to be watched for changes. If not supplied, this...
[ "Initialises", "an", "HttpWatcherServer", "to", "watch", "the", "given", "path", "for", "changes", ".", "Watches", "until", "the", "IO", "loop", "is", "terminated", "or", "a", "keyboard", "interrupt", "is", "intercepted", "." ]
train
https://github.com/thanethomson/httpwatcher/blob/373bddf1af99f5cc84917b5c8d4075ce3725a2ad/httpwatcher/cmdline.py#L18-L54
inveniosoftware/invenio-collections
invenio_collections/query.py
Query.query
def query(self): """Parse query string using given grammar. :returns: AST that represents the query in the given grammar. """ tree = pypeg2.parse(self._query, parser(), whitespace="") for walker in query_walkers(): tree = tree.accept(walker) return tree
python
def query(self): """Parse query string using given grammar. :returns: AST that represents the query in the given grammar. """ tree = pypeg2.parse(self._query, parser(), whitespace="") for walker in query_walkers(): tree = tree.accept(walker) return tree
[ "def", "query", "(", "self", ")", ":", "tree", "=", "pypeg2", ".", "parse", "(", "self", ".", "_query", ",", "parser", "(", ")", ",", "whitespace", "=", "\"\"", ")", "for", "walker", "in", "query_walkers", "(", ")", ":", "tree", "=", "tree", ".", ...
Parse query string using given grammar. :returns: AST that represents the query in the given grammar.
[ "Parse", "query", "string", "using", "given", "grammar", "." ]
train
https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/query.py#L36-L44
delfick/nose-of-yeti
noseOfYeti/tokeniser/config.py
ConfigUtil.normalise_key
def normalise_key(self, key): """Make sure key is a valid python attribute""" key = key.replace('-', '_') if key.startswith("noy_"): key = key[4:] return key
python
def normalise_key(self, key): """Make sure key is a valid python attribute""" key = key.replace('-', '_') if key.startswith("noy_"): key = key[4:] return key
[ "def", "normalise_key", "(", "self", ",", "key", ")", ":", "key", "=", "key", ".", "replace", "(", "'-'", ",", "'_'", ")", "if", "key", ".", "startswith", "(", "\"noy_\"", ")", ":", "key", "=", "key", "[", "4", ":", "]", "return", "key" ]
Make sure key is a valid python attribute
[ "Make", "sure", "key", "is", "a", "valid", "python", "attribute" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/config.py#L38-L43
delfick/nose-of-yeti
noseOfYeti/tokeniser/config.py
ConfigUtil.find_value
def find_value(self, key): """Find a value and return it""" values = self.values if key not in values: raise AttributeError("Config has no value for {}".format(key)) val = values[key] if isinstance(val, Default): return val.val else: r...
python
def find_value(self, key): """Find a value and return it""" values = self.values if key not in values: raise AttributeError("Config has no value for {}".format(key)) val = values[key] if isinstance(val, Default): return val.val else: r...
[ "def", "find_value", "(", "self", ",", "key", ")", ":", "values", "=", "self", ".", "values", "if", "key", "not", "in", "values", ":", "raise", "AttributeError", "(", "\"Config has no value for {}\"", ".", "format", "(", "key", ")", ")", "val", "=", "val...
Find a value and return it
[ "Find", "a", "value", "and", "return", "it" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/config.py#L45-L55
delfick/nose-of-yeti
noseOfYeti/tokeniser/config.py
ConfigUtil.use_options
def use_options(self, options, extractor=None): """ If extractor isn't specified, then just update self.values with options. Otherwise update values with whatever the result of calling extractor with our template and these options returns Also make sure all keys...
python
def use_options(self, options, extractor=None): """ If extractor isn't specified, then just update self.values with options. Otherwise update values with whatever the result of calling extractor with our template and these options returns Also make sure all keys...
[ "def", "use_options", "(", "self", ",", "options", ",", "extractor", "=", "None", ")", ":", "# Extract if necessary", "if", "not", "extractor", ":", "extracted", "=", "options", "else", ":", "extracted", "=", "extractor", "(", "self", ".", "template", ",", ...
If extractor isn't specified, then just update self.values with options. Otherwise update values with whatever the result of calling extractor with our template and these options returns Also make sure all keys are transformed into valid python attribute names
[ "If", "extractor", "isn", "t", "specified", "then", "just", "update", "self", ".", "values", "with", "options", "." ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/config.py#L57-L80
delfick/nose-of-yeti
noseOfYeti/tokeniser/config.py
ConfigUtil.find_config_file
def find_config_file(self): """ Find where our config file is if there is any If the value for the config file is a default and it doesn't exist then it is silently ignored. If however, the value isn't a default and it doesn't exist, an error is raised "...
python
def find_config_file(self): """ Find where our config file is if there is any If the value for the config file is a default and it doesn't exist then it is silently ignored. If however, the value isn't a default and it doesn't exist, an error is raised "...
[ "def", "find_config_file", "(", "self", ")", ":", "filename", "=", "self", ".", "values", ".", "get", "(", "'config_file'", ",", "Default", "(", "'noy.json'", ")", ")", "ignore_missing", "=", "False", "if", "isinstance", "(", "filename", ",", "Default", ")...
Find where our config file is if there is any If the value for the config file is a default and it doesn't exist then it is silently ignored. If however, the value isn't a default and it doesn't exist, an error is raised
[ "Find", "where", "our", "config", "file", "is", "if", "there", "is", "any" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/config.py#L82-L102
delfick/nose-of-yeti
noseOfYeti/tokeniser/config.py
ConfigUtil.apply_config_file
def apply_config_file(self, filename): """ Add options from config file to self.values Leave alone existing values that are not an instance of Default """ def extractor(template, options): """Ignore things that are existing non default values""" fo...
python
def apply_config_file(self, filename): """ Add options from config file to self.values Leave alone existing values that are not an instance of Default """ def extractor(template, options): """Ignore things that are existing non default values""" fo...
[ "def", "apply_config_file", "(", "self", ",", "filename", ")", ":", "def", "extractor", "(", "template", ",", "options", ")", ":", "\"\"\"Ignore things that are existing non default values\"\"\"", "for", "name", ",", "val", "in", "options", ":", "normalised", "=", ...
Add options from config file to self.values Leave alone existing values that are not an instance of Default
[ "Add", "options", "from", "config", "file", "to", "self", ".", "values", "Leave", "alone", "existing", "values", "that", "are", "not", "an", "instance", "of", "Default" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/config.py#L104-L119
delfick/nose-of-yeti
noseOfYeti/tokeniser/config.py
ConfigUtil.use_config_file
def use_config_file(self): """Find and apply the config file""" self.config_file = self.find_config_file() if self.config_file: self.apply_config_file(self.config_file)
python
def use_config_file(self): """Find and apply the config file""" self.config_file = self.find_config_file() if self.config_file: self.apply_config_file(self.config_file)
[ "def", "use_config_file", "(", "self", ")", ":", "self", ".", "config_file", "=", "self", ".", "find_config_file", "(", ")", "if", "self", ".", "config_file", ":", "self", ".", "apply_config_file", "(", "self", ".", "config_file", ")" ]
Find and apply the config file
[ "Find", "and", "apply", "the", "config", "file" ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/config.py#L121-L125
delfick/nose-of-yeti
noseOfYeti/tokeniser/config.py
Config.setup
def setup(self, options=None, extractor=None): """ Put options onto the config and put anything from a config file onto the config. If extractor is specified, it is used to extract values from the options dictionary """ # Get our programmatic options self._util.u...
python
def setup(self, options=None, extractor=None): """ Put options onto the config and put anything from a config file onto the config. If extractor is specified, it is used to extract values from the options dictionary """ # Get our programmatic options self._util.u...
[ "def", "setup", "(", "self", ",", "options", "=", "None", ",", "extractor", "=", "None", ")", ":", "# Get our programmatic options", "self", ".", "_util", ".", "use_options", "(", "options", ",", "extractor", ")", "# Overwrite non defaults in self.values with values...
Put options onto the config and put anything from a config file onto the config. If extractor is specified, it is used to extract values from the options dictionary
[ "Put", "options", "onto", "the", "config", "and", "put", "anything", "from", "a", "config", "file", "onto", "the", "config", "." ]
train
https://github.com/delfick/nose-of-yeti/blob/0b545ff350cebd59b40b601333c13033ce40d6dc/noseOfYeti/tokeniser/config.py#L144-L154
commonwealth-of-puerto-rico/libre
libre/apps/origins/utils.py
recursive_asdict
def recursive_asdict(d): """Convert Suds object into serializable format.""" out = {} for k, v in asdict(d).iteritems(): if hasattr(v, '__keylist__'): out[k] = recursive_asdict(v) elif isinstance(v, list): out[k] = [] for item in v: if hasa...
python
def recursive_asdict(d): """Convert Suds object into serializable format.""" out = {} for k, v in asdict(d).iteritems(): if hasattr(v, '__keylist__'): out[k] = recursive_asdict(v) elif isinstance(v, list): out[k] = [] for item in v: if hasa...
[ "def", "recursive_asdict", "(", "d", ")", ":", "out", "=", "{", "}", "for", "k", ",", "v", "in", "asdict", "(", "d", ")", ".", "iteritems", "(", ")", ":", "if", "hasattr", "(", "v", ",", "'__keylist__'", ")", ":", "out", "[", "k", "]", "=", "...
Convert Suds object into serializable format.
[ "Convert", "Suds", "object", "into", "serializable", "format", "." ]
train
https://github.com/commonwealth-of-puerto-rico/libre/blob/5b32f4ab068b515d2ea652b182e161271ba874e8/libre/apps/origins/utils.py#L4-L19
inveniosoftware/invenio-collections
examples/app.py
index
def index(): """Query Elasticsearch using "collection" param in query string.""" collection_names = request.values.getlist('collection') # Validation of collection names. collections = Collection.query if collection_names: collections = collections.filter( Collection.name.in_(co...
python
def index(): """Query Elasticsearch using "collection" param in query string.""" collection_names = request.values.getlist('collection') # Validation of collection names. collections = Collection.query if collection_names: collections = collections.filter( Collection.name.in_(co...
[ "def", "index", "(", ")", ":", "collection_names", "=", "request", ".", "values", ".", "getlist", "(", "'collection'", ")", "# Validation of collection names.", "collections", "=", "Collection", ".", "query", "if", "collection_names", ":", "collections", "=", "col...
Query Elasticsearch using "collection" param in query string.
[ "Query", "Elasticsearch", "using", "collection", "param", "in", "query", "string", "." ]
train
https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/examples/app.py#L150-L174
Galarzaa90/tibia.py
tibiapy/world.py
World.from_content
def from_content(cls, content): """Parses a Tibia.com response into a :class:`World`. Parameters ---------- content: :class:`str` The raw HTML from the server's information page. Returns ------- :class:`World` The World described in the p...
python
def from_content(cls, content): """Parses a Tibia.com response into a :class:`World`. Parameters ---------- content: :class:`str` The raw HTML from the server's information page. Returns ------- :class:`World` The World described in the p...
[ "def", "from_content", "(", "cls", ",", "content", ")", ":", "parsed_content", "=", "parse_tibiacom_content", "(", "content", ")", "tables", "=", "cls", ".", "_parse_tables", "(", "parsed_content", ")", "try", ":", "error", "=", "tables", ".", "get", "(", ...
Parses a Tibia.com response into a :class:`World`. Parameters ---------- content: :class:`str` The raw HTML from the server's information page. Returns ------- :class:`World` The World described in the page, or ``None``. Raises -...
[ "Parses", "a", "Tibia", ".", "com", "response", "into", "a", ":", "class", ":", "World", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/world.py#L220-L257
Galarzaa90/tibia.py
tibiapy/world.py
World.from_tibiadata
def from_tibiadata(cls, content): """Parses a TibiaData.com response into a :class:`World` Parameters ---------- content: :class:`str` The raw JSON content from TibiaData Returns ------- :class:`World` The World described in the page, or ...
python
def from_tibiadata(cls, content): """Parses a TibiaData.com response into a :class:`World` Parameters ---------- content: :class:`str` The raw JSON content from TibiaData Returns ------- :class:`World` The World described in the page, or ...
[ "def", "from_tibiadata", "(", "cls", ",", "content", ")", ":", "json_data", "=", "parse_json", "(", "content", ")", "try", ":", "world_data", "=", "json_data", "[", "\"world\"", "]", "world_info", "=", "world_data", "[", "\"world_information\"", "]", "world", ...
Parses a TibiaData.com response into a :class:`World` Parameters ---------- content: :class:`str` The raw JSON content from TibiaData Returns ------- :class:`World` The World described in the page, or ``None``. Raises ------ ...
[ "Parses", "a", "TibiaData", ".", "com", "response", "into", "a", ":", "class", ":", "World" ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/world.py#L260-L302
Galarzaa90/tibia.py
tibiapy/world.py
World._parse_world_info
def _parse_world_info(self, world_info_table): """ Parses the World Information table from Tibia.com and adds the found values to the object. Parameters ---------- world_info_table: :class:`list`[:class:`bs4.Tag`] """ world_info = {} for row in world_info...
python
def _parse_world_info(self, world_info_table): """ Parses the World Information table from Tibia.com and adds the found values to the object. Parameters ---------- world_info_table: :class:`list`[:class:`bs4.Tag`] """ world_info = {} for row in world_info...
[ "def", "_parse_world_info", "(", "self", ",", "world_info_table", ")", ":", "world_info", "=", "{", "}", "for", "row", "in", "world_info_table", ":", "cols_raw", "=", "row", ".", "find_all", "(", "'td'", ")", "cols", "=", "[", "ele", ".", "text", ".", ...
Parses the World Information table from Tibia.com and adds the found values to the object. Parameters ---------- world_info_table: :class:`list`[:class:`bs4.Tag`]
[ "Parses", "the", "World", "Information", "table", "from", "Tibia", ".", "com", "and", "adds", "the", "found", "values", "to", "the", "object", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/world.py#L306-L352
Galarzaa90/tibia.py
tibiapy/world.py
World._parse_battleye_status
def _parse_battleye_status(self, battleye_string): """Parses the BattlEye string and applies the results. Parameters ---------- battleye_string: :class:`str` String containing the world's Battleye Status. """ m = battleye_regexp.search(battleye_string) ...
python
def _parse_battleye_status(self, battleye_string): """Parses the BattlEye string and applies the results. Parameters ---------- battleye_string: :class:`str` String containing the world's Battleye Status. """ m = battleye_regexp.search(battleye_string) ...
[ "def", "_parse_battleye_status", "(", "self", ",", "battleye_string", ")", ":", "m", "=", "battleye_regexp", ".", "search", "(", "battleye_string", ")", "if", "m", ":", "self", ".", "battleye_protected", "=", "True", "self", ".", "battleye_date", "=", "parse_t...
Parses the BattlEye string and applies the results. Parameters ---------- battleye_string: :class:`str` String containing the world's Battleye Status.
[ "Parses", "the", "BattlEye", "string", "and", "applies", "the", "results", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/world.py#L354-L368
Galarzaa90/tibia.py
tibiapy/world.py
World._parse_tables
def _parse_tables(cls, parsed_content): """ Parses the information tables found in a world's information page. Parameters ---------- parsed_content: :class:`bs4.BeautifulSoup` A :class:`BeautifulSoup` object containing all the content. Returns ------...
python
def _parse_tables(cls, parsed_content): """ Parses the information tables found in a world's information page. Parameters ---------- parsed_content: :class:`bs4.BeautifulSoup` A :class:`BeautifulSoup` object containing all the content. Returns ------...
[ "def", "_parse_tables", "(", "cls", ",", "parsed_content", ")", ":", "tables", "=", "parsed_content", ".", "find_all", "(", "'div'", ",", "attrs", "=", "{", "'class'", ":", "'TableContainer'", "}", ")", "output", "=", "OrderedDict", "(", ")", "for", "table...
Parses the information tables found in a world's information page. Parameters ---------- parsed_content: :class:`bs4.BeautifulSoup` A :class:`BeautifulSoup` object containing all the content. Returns ------- :class:`OrderedDict`[:class:`str`, :class:`list`[:...
[ "Parses", "the", "information", "tables", "found", "in", "a", "world", "s", "information", "page", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/world.py#L371-L392
Galarzaa90/tibia.py
tibiapy/world.py
WorldOverview.from_content
def from_content(cls, content): """Parses the content of the World Overview section from Tibia.com into an object of this class. Parameters ---------- content: :class:`str` The HTML content of the World Overview page in Tibia.com Returns ------- :cla...
python
def from_content(cls, content): """Parses the content of the World Overview section from Tibia.com into an object of this class. Parameters ---------- content: :class:`str` The HTML content of the World Overview page in Tibia.com Returns ------- :cla...
[ "def", "from_content", "(", "cls", ",", "content", ")", ":", "parsed_content", "=", "parse_tibiacom_content", "(", "content", ",", "html_class", "=", "\"TableContentAndRightShadow\"", ")", "world_overview", "=", "WorldOverview", "(", ")", "try", ":", "record_row", ...
Parses the content of the World Overview section from Tibia.com into an object of this class. Parameters ---------- content: :class:`str` The HTML content of the World Overview page in Tibia.com Returns ------- :class:`WorldOverview` An instance ...
[ "Parses", "the", "content", "of", "the", "World", "Overview", "section", "from", "Tibia", ".", "com", "into", "an", "object", "of", "this", "class", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/world.py#L448-L479
Galarzaa90/tibia.py
tibiapy/world.py
WorldOverview.from_tibiadata
def from_tibiadata(cls, content): """Parses the content of the World Overview section from TibiaData.com into an object of this class. Notes ----- Due to TibiaData limitations, :py:attr:`record_count` and :py:attr:`record_date` are unavailable object. Additionally, the ...
python
def from_tibiadata(cls, content): """Parses the content of the World Overview section from TibiaData.com into an object of this class. Notes ----- Due to TibiaData limitations, :py:attr:`record_count` and :py:attr:`record_date` are unavailable object. Additionally, the ...
[ "def", "from_tibiadata", "(", "cls", ",", "content", ")", ":", "json_data", "=", "parse_json", "(", "content", ")", "try", ":", "worlds_json", "=", "json_data", "[", "\"worlds\"", "]", "[", "\"allworlds\"", "]", "world_overview", "=", "cls", "(", ")", "for...
Parses the content of the World Overview section from TibiaData.com into an object of this class. Notes ----- Due to TibiaData limitations, :py:attr:`record_count` and :py:attr:`record_date` are unavailable object. Additionally, the listed worlds in :py:attr:`worlds` lack some ...
[ "Parses", "the", "content", "of", "the", "World", "Overview", "section", "from", "TibiaData", ".", "com", "into", "an", "object", "of", "this", "class", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/world.py#L482-L524
Galarzaa90/tibia.py
tibiapy/world.py
WorldOverview._parse_worlds
def _parse_worlds(self, world_rows): """Parses the world columns and adds the results to :py:attr:`worlds`. Parameters ---------- world_rows: :class:`list` of :class:`bs4.Tag` A list containing the rows of each world. """ for world_row in world_rows: ...
python
def _parse_worlds(self, world_rows): """Parses the world columns and adds the results to :py:attr:`worlds`. Parameters ---------- world_rows: :class:`list` of :class:`bs4.Tag` A list containing the rows of each world. """ for world_row in world_rows: ...
[ "def", "_parse_worlds", "(", "self", ",", "world_rows", ")", ":", "for", "world_row", "in", "world_rows", ":", "cols", "=", "world_row", ".", "find_all", "(", "\"td\"", ")", "name", "=", "cols", "[", "0", "]", ".", "text", ".", "strip", "(", ")", "st...
Parses the world columns and adds the results to :py:attr:`worlds`. Parameters ---------- world_rows: :class:`list` of :class:`bs4.Tag` A list containing the rows of each world.
[ "Parses", "the", "world", "columns", "and", "adds", "the", "results", "to", ":", "py", ":", "attr", ":", "worlds", "." ]
train
https://github.com/Galarzaa90/tibia.py/blob/02ba1a8f1e18177ef5c7dcd44affc8d761d59e12/tibiapy/world.py#L526-L557
ff0000/scarlet
scarlet/assets/models.py
AssetBase.reset_crops
def reset_crops(self): """ Reset all known crops to the default crop. If settings.ASSET_CELERY is specified then the task will be run async """ if self._can_crop(): if settings.CELERY or settings.USE_CELERY_DECORATOR: # this means that we are...
python
def reset_crops(self): """ Reset all known crops to the default crop. If settings.ASSET_CELERY is specified then the task will be run async """ if self._can_crop(): if settings.CELERY or settings.USE_CELERY_DECORATOR: # this means that we are...
[ "def", "reset_crops", "(", "self", ")", ":", "if", "self", ".", "_can_crop", "(", ")", ":", "if", "settings", ".", "CELERY", "or", "settings", ".", "USE_CELERY_DECORATOR", ":", "# this means that we are using celery", "tasks", ".", "reset_crops", ".", "apply_asy...
Reset all known crops to the default crop. If settings.ASSET_CELERY is specified then the task will be run async
[ "Reset", "all", "known", "crops", "to", "the", "default", "crop", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/assets/models.py#L85-L98
ff0000/scarlet
scarlet/assets/models.py
AssetBase.ensure_crops
def ensure_crops(self, *required_crops): """ Make sure a crop exists for each crop in required_crops. Existing crops will not be changed. If settings.ASSET_CELERY is specified then the task will be run async """ if self._can_crop(): if settings.CELERY...
python
def ensure_crops(self, *required_crops): """ Make sure a crop exists for each crop in required_crops. Existing crops will not be changed. If settings.ASSET_CELERY is specified then the task will be run async """ if self._can_crop(): if settings.CELERY...
[ "def", "ensure_crops", "(", "self", ",", "*", "required_crops", ")", ":", "if", "self", ".", "_can_crop", "(", ")", ":", "if", "settings", ".", "CELERY", "or", "settings", ".", "USE_CELERY_DECORATOR", ":", "# this means that we are using celery", "args", "=", ...
Make sure a crop exists for each crop in required_crops. Existing crops will not be changed. If settings.ASSET_CELERY is specified then the task will be run async
[ "Make", "sure", "a", "crop", "exists", "for", "each", "crop", "in", "required_crops", ".", "Existing", "crops", "will", "not", "be", "changed", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/assets/models.py#L100-L114
ff0000/scarlet
scarlet/assets/models.py
AssetBase.create_crop
def create_crop(self, name, x, x2, y, y2): """ Create a crop for this asset. """ if self._can_crop(): spec = get_image_cropper().create_crop(name, self.file, x=x, x2=x2, y=y, y2=y2) ImageDetail.save_crop_spec(self...
python
def create_crop(self, name, x, x2, y, y2): """ Create a crop for this asset. """ if self._can_crop(): spec = get_image_cropper().create_crop(name, self.file, x=x, x2=x2, y=y, y2=y2) ImageDetail.save_crop_spec(self...
[ "def", "create_crop", "(", "self", ",", "name", ",", "x", ",", "x2", ",", "y", ",", "y2", ")", ":", "if", "self", ".", "_can_crop", "(", ")", ":", "spec", "=", "get_image_cropper", "(", ")", ".", "create_crop", "(", "name", ",", "self", ".", "fil...
Create a crop for this asset.
[ "Create", "a", "crop", "for", "this", "asset", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/assets/models.py#L116-L123
ff0000/scarlet
scarlet/assets/models.py
AssetBase.save
def save(self, *args, **kwargs): """ For new assets, creates a new slug. For updates, deletes the old file from storage. Calls super to actually save the object. """ if not self.pk and not self.slug: self.slug = self.generate_slug() if self.__origina...
python
def save(self, *args, **kwargs): """ For new assets, creates a new slug. For updates, deletes the old file from storage. Calls super to actually save the object. """ if not self.pk and not self.slug: self.slug = self.generate_slug() if self.__origina...
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "pk", "and", "not", "self", ".", "slug", ":", "self", ".", "slug", "=", "self", ".", "generate_slug", "(", ")", "if", "self", ".", "__ori...
For new assets, creates a new slug. For updates, deletes the old file from storage. Calls super to actually save the object.
[ "For", "new", "assets", "creates", "a", "new", "slug", ".", "For", "updates", "deletes", "the", "old", "file", "from", "storage", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/assets/models.py#L125-L172
ff0000/scarlet
scarlet/assets/models.py
AssetBase.delete
def delete(self, *args, **kwargs): """ Deletes the actual file from storage after the object is deleted. Calls super to actually delete the object. """ file_obj = self.file super(AssetBase, self).delete(*args, **kwargs) self.delete_real_file(file_obj)
python
def delete(self, *args, **kwargs): """ Deletes the actual file from storage after the object is deleted. Calls super to actually delete the object. """ file_obj = self.file super(AssetBase, self).delete(*args, **kwargs) self.delete_real_file(file_obj)
[ "def", "delete", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "file_obj", "=", "self", ".", "file", "super", "(", "AssetBase", ",", "self", ")", ".", "delete", "(", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "d...
Deletes the actual file from storage after the object is deleted. Calls super to actually delete the object.
[ "Deletes", "the", "actual", "file", "from", "storage", "after", "the", "object", "is", "deleted", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/assets/models.py#L174-L182
clchiou/startup
startup.py
_get_not_annotated
def _get_not_annotated(func, annotations=None): """Return non-optional parameters that are not annotated.""" argspec = inspect.getfullargspec(func) args = argspec.args if argspec.defaults is not None: args = args[:-len(argspec.defaults)] if inspect.isclass(func) or inspect.ismethod(func): ...
python
def _get_not_annotated(func, annotations=None): """Return non-optional parameters that are not annotated.""" argspec = inspect.getfullargspec(func) args = argspec.args if argspec.defaults is not None: args = args[:-len(argspec.defaults)] if inspect.isclass(func) or inspect.ismethod(func): ...
[ "def", "_get_not_annotated", "(", "func", ",", "annotations", "=", "None", ")", ":", "argspec", "=", "inspect", ".", "getfullargspec", "(", "func", ")", "args", "=", "argspec", ".", "args", "if", "argspec", ".", "defaults", "is", "not", "None", ":", "arg...
Return non-optional parameters that are not annotated.
[ "Return", "non", "-", "optional", "parameters", "that", "are", "not", "annotated", "." ]
train
https://github.com/clchiou/startup/blob/13cbf3ce1deffbc10d33a5f64c396a73129a5929/startup.py#L224-L236
clchiou/startup
startup.py
_parse_args
def _parse_args(func, variables, annotations=None): """Return a list of arguments with the variable it reads. NOTE: Multiple arguments may read the same variable. """ arg_read_var = [] for arg_name, anno in (annotations or func.__annotations__).items(): if arg_name == 'return': ...
python
def _parse_args(func, variables, annotations=None): """Return a list of arguments with the variable it reads. NOTE: Multiple arguments may read the same variable. """ arg_read_var = [] for arg_name, anno in (annotations or func.__annotations__).items(): if arg_name == 'return': ...
[ "def", "_parse_args", "(", "func", ",", "variables", ",", "annotations", "=", "None", ")", ":", "arg_read_var", "=", "[", "]", "for", "arg_name", ",", "anno", "in", "(", "annotations", "or", "func", ".", "__annotations__", ")", ".", "items", "(", ")", ...
Return a list of arguments with the variable it reads. NOTE: Multiple arguments may read the same variable.
[ "Return", "a", "list", "of", "arguments", "with", "the", "variable", "it", "reads", "." ]
train
https://github.com/clchiou/startup/blob/13cbf3ce1deffbc10d33a5f64c396a73129a5929/startup.py#L239-L251
clchiou/startup
startup.py
_parse_arg
def _parse_arg(func, variables, arg_name, anno): """Parse an argument's annotation.""" if isinstance(anno, str): var = variables[anno] return var, var.read_latest elif (isinstance(anno, list) and len(anno) == 1 and isinstance(anno[0], str)): var = variables[anno[0]] ...
python
def _parse_arg(func, variables, arg_name, anno): """Parse an argument's annotation.""" if isinstance(anno, str): var = variables[anno] return var, var.read_latest elif (isinstance(anno, list) and len(anno) == 1 and isinstance(anno[0], str)): var = variables[anno[0]] ...
[ "def", "_parse_arg", "(", "func", ",", "variables", ",", "arg_name", ",", "anno", ")", ":", "if", "isinstance", "(", "anno", ",", "str", ")", ":", "var", "=", "variables", "[", "anno", "]", "return", "var", ",", "var", ".", "read_latest", "elif", "("...
Parse an argument's annotation.
[ "Parse", "an", "argument", "s", "annotation", "." ]
train
https://github.com/clchiou/startup/blob/13cbf3ce1deffbc10d33a5f64c396a73129a5929/startup.py#L254-L268
clchiou/startup
startup.py
_parse_ret
def _parse_ret(func, variables, annotations=None): """Parse func's return annotation and return either None, a variable, or a tuple of variables. NOTE: * _parse_ret() also notifies variables about will-writes. * A variable can be written multiple times per return annotation. """ anno = ...
python
def _parse_ret(func, variables, annotations=None): """Parse func's return annotation and return either None, a variable, or a tuple of variables. NOTE: * _parse_ret() also notifies variables about will-writes. * A variable can be written multiple times per return annotation. """ anno = ...
[ "def", "_parse_ret", "(", "func", ",", "variables", ",", "annotations", "=", "None", ")", ":", "anno", "=", "(", "annotations", "or", "func", ".", "__annotations__", ")", ".", "get", "(", "'return'", ")", "if", "anno", "is", "None", ":", "return", "Non...
Parse func's return annotation and return either None, a variable, or a tuple of variables. NOTE: * _parse_ret() also notifies variables about will-writes. * A variable can be written multiple times per return annotation.
[ "Parse", "func", "s", "return", "annotation", "and", "return", "either", "None", "a", "variable", "or", "a", "tuple", "of", "variables", "." ]
train
https://github.com/clchiou/startup/blob/13cbf3ce1deffbc10d33a5f64c396a73129a5929/startup.py#L271-L294
clchiou/startup
startup.py
_write_values
def _write_values(kwargs, variables): """Write values of kwargs and return thus-satisfied closures.""" writeto = [] for var_name, value in kwargs.items(): var = variables[var_name] var.notify_will_write() var.write(value) writeto.append(var) return _notify_reader_writes(w...
python
def _write_values(kwargs, variables): """Write values of kwargs and return thus-satisfied closures.""" writeto = [] for var_name, value in kwargs.items(): var = variables[var_name] var.notify_will_write() var.write(value) writeto.append(var) return _notify_reader_writes(w...
[ "def", "_write_values", "(", "kwargs", ",", "variables", ")", ":", "writeto", "=", "[", "]", "for", "var_name", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", "var", "=", "variables", "[", "var_name", "]", "var", ".", "notify_will_write", "...
Write values of kwargs and return thus-satisfied closures.
[ "Write", "values", "of", "kwargs", "and", "return", "thus", "-", "satisfied", "closures", "." ]
train
https://github.com/clchiou/startup/blob/13cbf3ce1deffbc10d33a5f64c396a73129a5929/startup.py#L297-L305
clchiou/startup
startup.py
_notify_reader_writes
def _notify_reader_writes(writeto): """Notify reader closures about these writes and return a sorted list of thus-satisfied closures. """ satisfied = [] for var in writeto: if var.readable: for reader in var.readers: reader.notify_read_ready() i...
python
def _notify_reader_writes(writeto): """Notify reader closures about these writes and return a sorted list of thus-satisfied closures. """ satisfied = [] for var in writeto: if var.readable: for reader in var.readers: reader.notify_read_ready() i...
[ "def", "_notify_reader_writes", "(", "writeto", ")", ":", "satisfied", "=", "[", "]", "for", "var", "in", "writeto", ":", "if", "var", ".", "readable", ":", "for", "reader", "in", "var", ".", "readers", ":", "reader", ".", "notify_read_ready", "(", ")", ...
Notify reader closures about these writes and return a sorted list of thus-satisfied closures.
[ "Notify", "reader", "closures", "about", "these", "writes", "and", "return", "a", "sorted", "list", "of", "thus", "-", "satisfied", "closures", "." ]
train
https://github.com/clchiou/startup/blob/13cbf3ce1deffbc10d33a5f64c396a73129a5929/startup.py#L308-L319
clchiou/startup
startup.py
Startup._release
def _release(self): """Destroy self since closures cannot be called again.""" del self.funcs del self.variables del self.variable_values del self.satisfied
python
def _release(self): """Destroy self since closures cannot be called again.""" del self.funcs del self.variables del self.variable_values del self.satisfied
[ "def", "_release", "(", "self", ")", ":", "del", "self", ".", "funcs", "del", "self", ".", "variables", "del", "self", ".", "variable_values", "del", "self", ".", "satisfied" ]
Destroy self since closures cannot be called again.
[ "Destroy", "self", "since", "closures", "cannot", "be", "called", "again", "." ]
train
https://github.com/clchiou/startup/blob/13cbf3ce1deffbc10d33a5f64c396a73129a5929/startup.py#L134-L139
clchiou/startup
startup.py
Startup.set
def set(self, name, value): """Set a variable before ``call()``.""" if not hasattr(self, 'funcs'): raise StartupError('startup cannot be called again') self.variable_values[name] = value
python
def set(self, name, value): """Set a variable before ``call()``.""" if not hasattr(self, 'funcs'): raise StartupError('startup cannot be called again') self.variable_values[name] = value
[ "def", "set", "(", "self", ",", "name", ",", "value", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'funcs'", ")", ":", "raise", "StartupError", "(", "'startup cannot be called again'", ")", "self", ".", "variable_values", "[", "name", "]", "=", "...
Set a variable before ``call()``.
[ "Set", "a", "variable", "before", "call", "()", "." ]
train
https://github.com/clchiou/startup/blob/13cbf3ce1deffbc10d33a5f64c396a73129a5929/startup.py#L179-L183
clchiou/startup
startup.py
Startup.call
def call(self, **kwargs): """Call all the functions that have previously been added to the dependency graph in topological and lexicographical order, and then return variables in a ``dict``. You may provide variable values with keyword arguments. These values will be written an...
python
def call(self, **kwargs): """Call all the functions that have previously been added to the dependency graph in topological and lexicographical order, and then return variables in a ``dict``. You may provide variable values with keyword arguments. These values will be written an...
[ "def", "call", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'funcs'", ")", ":", "raise", "StartupError", "(", "'startup cannot be called again'", ")", "for", "name", ",", "var", "in", "self", ".", "variables"...
Call all the functions that have previously been added to the dependency graph in topological and lexicographical order, and then return variables in a ``dict``. You may provide variable values with keyword arguments. These values will be written and can satisfy dependencies. ...
[ "Call", "all", "the", "functions", "that", "have", "previously", "been", "added", "to", "the", "dependency", "graph", "in", "topological", "and", "lexicographical", "order", "and", "then", "return", "variables", "in", "a", "dict", "." ]
train
https://github.com/clchiou/startup/blob/13cbf3ce1deffbc10d33a5f64c396a73129a5929/startup.py#L185-L218
clchiou/startup
startup.py
Variable.write
def write(self, value): """Write a (new) value to this variable.""" assert self.num_write_waits > 0, self self.num_write_waits -= 1 self.values.append(value) if self.readable: LOG.debug('%s is now readable', self.name)
python
def write(self, value): """Write a (new) value to this variable.""" assert self.num_write_waits > 0, self self.num_write_waits -= 1 self.values.append(value) if self.readable: LOG.debug('%s is now readable', self.name)
[ "def", "write", "(", "self", ",", "value", ")", ":", "assert", "self", ".", "num_write_waits", ">", "0", ",", "self", "self", ".", "num_write_waits", "-=", "1", "self", ".", "values", ".", "append", "(", "value", ")", "if", "self", ".", "readable", "...
Write a (new) value to this variable.
[ "Write", "a", "(", "new", ")", "value", "to", "this", "variable", "." ]
train
https://github.com/clchiou/startup/blob/13cbf3ce1deffbc10d33a5f64c396a73129a5929/startup.py#L350-L356
clchiou/startup
startup.py
Closure.call
def call(self): """Call the closure and return variable(s) that is written.""" assert self.satisfied, self LOG.debug('call %s.%s', self.func.__module__, self.func.__qualname__) kwargs = {arg.name: arg.read() for arg in self.args} out_value = self.func(**kwargs) if self.wr...
python
def call(self): """Call the closure and return variable(s) that is written.""" assert self.satisfied, self LOG.debug('call %s.%s', self.func.__module__, self.func.__qualname__) kwargs = {arg.name: arg.read() for arg in self.args} out_value = self.func(**kwargs) if self.wr...
[ "def", "call", "(", "self", ")", ":", "assert", "self", ".", "satisfied", ",", "self", "LOG", ".", "debug", "(", "'call %s.%s'", ",", "self", ".", "func", ".", "__module__", ",", "self", ".", "func", ".", "__qualname__", ")", "kwargs", "=", "{", "arg...
Call the closure and return variable(s) that is written.
[ "Call", "the", "closure", "and", "return", "variable", "(", "s", ")", "that", "is", "written", "." ]
train
https://github.com/clchiou/startup/blob/13cbf3ce1deffbc10d33a5f64c396a73129a5929/startup.py#L416-L434
klahnakoski/pyLibrary
jx_elasticsearch/es52/__init__.py
ES52.update
def update(self, command): """ EXPECTING command == {"set":term, "where":where} THE set CLAUSE IS A DICT MAPPING NAMES TO VALUES THE where CLAUSE IS AN ES FILTER """ command = wrap(command) table = self.get_table(command['update']) es_index = self.es.clus...
python
def update(self, command): """ EXPECTING command == {"set":term, "where":where} THE set CLAUSE IS A DICT MAPPING NAMES TO VALUES THE where CLAUSE IS AN ES FILTER """ command = wrap(command) table = self.get_table(command['update']) es_index = self.es.clus...
[ "def", "update", "(", "self", ",", "command", ")", ":", "command", "=", "wrap", "(", "command", ")", "table", "=", "self", ".", "get_table", "(", "command", "[", "'update'", "]", ")", "es_index", "=", "self", ".", "es", ".", "cluster", ".", "get_inde...
EXPECTING command == {"set":term, "where":where} THE set CLAUSE IS A DICT MAPPING NAMES TO VALUES THE where CLAUSE IS AN ES FILTER
[ "EXPECTING", "command", "==", "{", "set", ":", "term", "where", ":", "where", "}", "THE", "set", "CLAUSE", "IS", "A", "DICT", "MAPPING", "NAMES", "TO", "VALUES", "THE", "where", "CLAUSE", "IS", "AN", "ES", "FILTER" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/jx_elasticsearch/es52/__init__.py#L226-L278
tetframework/Tonnikala
tonnikala/i18n/__init__.py
extract_tonnikala
def extract_tonnikala(fileobj, keywords, comment_tags, options): """Extract messages from Tonnikala files. :param fileobj: the file-like object the messages should be extracted from :param keywords: a list of keywords (i.e. function names) that should be recognized ...
python
def extract_tonnikala(fileobj, keywords, comment_tags, options): """Extract messages from Tonnikala files. :param fileobj: the file-like object the messages should be extracted from :param keywords: a list of keywords (i.e. function names) that should be recognized ...
[ "def", "extract_tonnikala", "(", "fileobj", ",", "keywords", ",", "comment_tags", ",", "options", ")", ":", "extractor", "=", "TonnikalaExtractor", "(", ")", "for", "msg", "in", "extractor", "(", "filename", "=", "None", ",", "fileobj", "=", "fileobj", ",", ...
Extract messages from Tonnikala files. :param fileobj: the file-like object the messages should be extracted from :param keywords: a list of keywords (i.e. function names) that should be recognized as translation functions :param comment_tags: a list of translator t...
[ "Extract", "messages", "from", "Tonnikala", "files", "." ]
train
https://github.com/tetframework/Tonnikala/blob/99d168657da1b2372ff898254f80808ea8d1b83f/tonnikala/i18n/__init__.py#L57-L84
msikma/kanaconv
kanaconv/converter.py
KanaConv._clear_char
def _clear_char(self): ''' Clears the current character and makes the machine ready to accept the next character. ''' self.lvmarker_count = 0 self.geminate_count = 0 self.next_char_info = None self.next_char_type = None self.active_vowel = None ...
python
def _clear_char(self): ''' Clears the current character and makes the machine ready to accept the next character. ''' self.lvmarker_count = 0 self.geminate_count = 0 self.next_char_info = None self.next_char_type = None self.active_vowel = None ...
[ "def", "_clear_char", "(", "self", ")", ":", "self", ".", "lvmarker_count", "=", "0", "self", ".", "geminate_count", "=", "0", "self", ".", "next_char_info", "=", "None", "self", ".", "next_char_type", "=", "None", "self", ".", "active_vowel", "=", "None",...
Clears the current character and makes the machine ready to accept the next character.
[ "Clears", "the", "current", "character", "and", "makes", "the", "machine", "ready", "to", "accept", "the", "next", "character", "." ]
train
https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/converter.py#L206-L228
msikma/kanaconv
kanaconv/converter.py
KanaConv._append_unknown_char
def _append_unknown_char(self): ''' Appends the unknown character, in case one was encountered. ''' if self.unknown_strategy == UNKNOWN_INCLUDE and \ self.unknown_char is not None: self._append_to_stack(self.unknown_char) self.unknown_char = None
python
def _append_unknown_char(self): ''' Appends the unknown character, in case one was encountered. ''' if self.unknown_strategy == UNKNOWN_INCLUDE and \ self.unknown_char is not None: self._append_to_stack(self.unknown_char) self.unknown_char = None
[ "def", "_append_unknown_char", "(", "self", ")", ":", "if", "self", ".", "unknown_strategy", "==", "UNKNOWN_INCLUDE", "and", "self", ".", "unknown_char", "is", "not", "None", ":", "self", ".", "_append_to_stack", "(", "self", ".", "unknown_char", ")", "self", ...
Appends the unknown character, in case one was encountered.
[ "Appends", "the", "unknown", "character", "in", "case", "one", "was", "encountered", "." ]
train
https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/converter.py#L256-L264
msikma/kanaconv
kanaconv/converter.py
KanaConv._flush_char
def _flush_char(self): ''' Appends the rōmaji characters that represent the current state of the machine. For example, if the state includes the character ト, plus a geminate marker and a long vowel marker, this causes the characters "ttō" to be added to the output. ''' ...
python
def _flush_char(self): ''' Appends the rōmaji characters that represent the current state of the machine. For example, if the state includes the character ト, plus a geminate marker and a long vowel marker, this causes the characters "ttō" to be added to the output. ''' ...
[ "def", "_flush_char", "(", "self", ")", ":", "# Ignore in case there's no active character, only at the", "# first iteration of the conversion process.", "if", "self", ".", "active_char", "is", "None", ":", "if", "self", ".", "unknown_char", "is", "not", "None", ":", "s...
Appends the rōmaji characters that represent the current state of the machine. For example, if the state includes the character ト, plus a geminate marker and a long vowel marker, this causes the characters "ttō" to be added to the output.
[ "Appends", "the", "rōmaji", "characters", "that", "represent", "the", "current", "state", "of", "the", "machine", ".", "For", "example", "if", "the", "state", "includes", "the", "character", "ト", "plus", "a", "geminate", "marker", "and", "a", "long", "vowel"...
train
https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/converter.py#L266-L408
msikma/kanaconv
kanaconv/converter.py
KanaConv._promote_solitary_xvowel
def _promote_solitary_xvowel(self): ''' "Promotes" the current xvowel to a regular vowel, in case it is not otherwise connected to a character. Used to print small vowels that would otherwise get lost; normally small vowels always form a pair, but in case one is by itself...
python
def _promote_solitary_xvowel(self): ''' "Promotes" the current xvowel to a regular vowel, in case it is not otherwise connected to a character. Used to print small vowels that would otherwise get lost; normally small vowels always form a pair, but in case one is by itself...
[ "def", "_promote_solitary_xvowel", "(", "self", ")", ":", "char_type", "=", "self", ".", "active_char_type", "# Only promote if we actually have an xvowel, and if the currently", "# active character is not a consonant-vowel pair or vowel.", "if", "char_type", "==", "VOWEL", "or", ...
"Promotes" the current xvowel to a regular vowel, in case it is not otherwise connected to a character. Used to print small vowels that would otherwise get lost; normally small vowels always form a pair, but in case one is by itself it should basically act like a regular vowel.
[ "Promotes", "the", "current", "xvowel", "to", "a", "regular", "vowel", "in", "case", "it", "is", "not", "otherwise", "connected", "to", "a", "character", ".", "Used", "to", "print", "small", "vowels", "that", "would", "otherwise", "get", "lost", ";", "norm...
train
https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/converter.py#L416-L433
msikma/kanaconv
kanaconv/converter.py
KanaConv._add_unknown_char
def _add_unknown_char(self, string): ''' Adds an unknown character to the stack. ''' if self.has_xvowel: # Ensure an xvowel gets printed if we've got an active # one right now. self._promote_solitary_xvowel() self.unknown_char = string ...
python
def _add_unknown_char(self, string): ''' Adds an unknown character to the stack. ''' if self.has_xvowel: # Ensure an xvowel gets printed if we've got an active # one right now. self._promote_solitary_xvowel() self.unknown_char = string ...
[ "def", "_add_unknown_char", "(", "self", ",", "string", ")", ":", "if", "self", ".", "has_xvowel", ":", "# Ensure an xvowel gets printed if we've got an active", "# one right now.", "self", ".", "_promote_solitary_xvowel", "(", ")", "self", ".", "unknown_char", "=", "...
Adds an unknown character to the stack.
[ "Adds", "an", "unknown", "character", "to", "the", "stack", "." ]
train
https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/converter.py#L435-L445
msikma/kanaconv
kanaconv/converter.py
KanaConv._set_digraph_a
def _set_digraph_a(self, char): ''' Sets the currently active character, in case it is (potentially) the first part of a digraph. ''' self._set_char(char, CV) self.active_dgr_a_info = di_a_lt[char]
python
def _set_digraph_a(self, char): ''' Sets the currently active character, in case it is (potentially) the first part of a digraph. ''' self._set_char(char, CV) self.active_dgr_a_info = di_a_lt[char]
[ "def", "_set_digraph_a", "(", "self", ",", "char", ")", ":", "self", ".", "_set_char", "(", "char", ",", "CV", ")", "self", ".", "active_dgr_a_info", "=", "di_a_lt", "[", "char", "]" ]
Sets the currently active character, in case it is (potentially) the first part of a digraph.
[ "Sets", "the", "currently", "active", "character", "in", "case", "it", "is", "(", "potentially", ")", "the", "first", "part", "of", "a", "digraph", "." ]
train
https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/converter.py#L447-L453
msikma/kanaconv
kanaconv/converter.py
KanaConv._set_digraph_b
def _set_digraph_b(self, char): ''' Sets the second part of a digraph. ''' self.has_digraph_b = True # Change the active vowel to the one provided by the second part # of the digraph. self.active_vowel_ro = di_b_lt[char][0] self.active_dgr_b_info = di_b_lt...
python
def _set_digraph_b(self, char): ''' Sets the second part of a digraph. ''' self.has_digraph_b = True # Change the active vowel to the one provided by the second part # of the digraph. self.active_vowel_ro = di_b_lt[char][0] self.active_dgr_b_info = di_b_lt...
[ "def", "_set_digraph_b", "(", "self", ",", "char", ")", ":", "self", ".", "has_digraph_b", "=", "True", "# Change the active vowel to the one provided by the second part", "# of the digraph.", "self", ".", "active_vowel_ro", "=", "di_b_lt", "[", "char", "]", "[", "0",...
Sets the second part of a digraph.
[ "Sets", "the", "second", "part", "of", "a", "digraph", "." ]
train
https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/converter.py#L455-L463
msikma/kanaconv
kanaconv/converter.py
KanaConv._char_ro_vowel
def _char_ro_vowel(self, char_info, type): ''' Returns the vowel part of a character in rōmaji. ''' if type == CV: return char_info[3] if type == VOWEL or type == XVOWEL: return char_info[0] return None
python
def _char_ro_vowel(self, char_info, type): ''' Returns the vowel part of a character in rōmaji. ''' if type == CV: return char_info[3] if type == VOWEL or type == XVOWEL: return char_info[0] return None
[ "def", "_char_ro_vowel", "(", "self", ",", "char_info", ",", "type", ")", ":", "if", "type", "==", "CV", ":", "return", "char_info", "[", "3", "]", "if", "type", "==", "VOWEL", "or", "type", "==", "XVOWEL", ":", "return", "char_info", "[", "0", "]", ...
Returns the vowel part of a character in rōmaji.
[ "Returns", "the", "vowel", "part", "of", "a", "character", "in", "rōmaji", "." ]
train
https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/converter.py#L480-L490
msikma/kanaconv
kanaconv/converter.py
KanaConv._set_char
def _set_char(self, char, type): ''' Sets the currently active character, e.g. ト. We save some information about the character as well. active_char_info contains the full tuple of rōmaji info, and active_ro_vowel contains e.g. 'o' for ト. We also set the character type: either a ...
python
def _set_char(self, char, type): ''' Sets the currently active character, e.g. ト. We save some information about the character as well. active_char_info contains the full tuple of rōmaji info, and active_ro_vowel contains e.g. 'o' for ト. We also set the character type: either a ...
[ "def", "_set_char", "(", "self", ",", "char", ",", "type", ")", ":", "self", ".", "next_char_info", "=", "self", ".", "_char_lookup", "(", "char", ")", "self", ".", "next_char_type", "=", "type", "self", ".", "_flush_char", "(", ")", "self", ".", "acti...
Sets the currently active character, e.g. ト. We save some information about the character as well. active_char_info contains the full tuple of rōmaji info, and active_ro_vowel contains e.g. 'o' for ト. We also set the character type: either a consonant-vowel pair or a vowel. This affects...
[ "Sets", "the", "currently", "active", "character", "e", ".", "g", ".", "ト", ".", "We", "save", "some", "information", "about", "the", "character", "as", "well", ".", "active_char_info", "contains", "the", "full", "tuple", "of", "rōmaji", "info", "and", "ac...
train
https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/converter.py#L492-L509
msikma/kanaconv
kanaconv/converter.py
KanaConv._set_vowel
def _set_vowel(self, vowel): ''' Sets the currently active vowel, e.g. ア. Vowels act slightly differently from other characters. If one succeeds the same vowel (or consonant-vowel pair with the same vowel) then it acts like a long vowel marker. E.g. おねえ becomes onē. Hen...
python
def _set_vowel(self, vowel): ''' Sets the currently active vowel, e.g. ア. Vowels act slightly differently from other characters. If one succeeds the same vowel (or consonant-vowel pair with the same vowel) then it acts like a long vowel marker. E.g. おねえ becomes onē. Hen...
[ "def", "_set_vowel", "(", "self", ",", "vowel", ")", ":", "vowel_info", "=", "kana_lt", "[", "vowel", "]", "vowel_ro", "=", "self", ".", "active_vowel_ro", "if", "self", ".", "_is_long_vowel", "(", "vowel_ro", ",", "vowel_info", "[", "0", "]", ")", ":", ...
Sets the currently active vowel, e.g. ア. Vowels act slightly differently from other characters. If one succeeds the same vowel (or consonant-vowel pair with the same vowel) then it acts like a long vowel marker. E.g. おねえ becomes onē. Hence, either we increment the long vowel marker cou...
[ "Sets", "the", "currently", "active", "vowel", "e", ".", "g", ".", "ア", "." ]
train
https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/converter.py#L519-L551
msikma/kanaconv
kanaconv/converter.py
KanaConv._set_xvowel
def _set_xvowel(self, xvowel): ''' Sets the currently active small vowel, e.g. ァ. If an active small vowel has already been set, the current character must be flushed. (Double small vowels don't occur in dictionary words.) After that, we'll set the current character to this smal...
python
def _set_xvowel(self, xvowel): ''' Sets the currently active small vowel, e.g. ァ. If an active small vowel has already been set, the current character must be flushed. (Double small vowels don't occur in dictionary words.) After that, we'll set the current character to this smal...
[ "def", "_set_xvowel", "(", "self", ",", "xvowel", ")", ":", "xvowel_info", "=", "kana_lt", "[", "xvowel", "]", "vowel_info", "=", "self", ".", "active_vowel_info", "dgr_b_info", "=", "None", "# Special case: if the currently active character is 'n', we must", "# flush t...
Sets the currently active small vowel, e.g. ァ. If an active small vowel has already been set, the current character must be flushed. (Double small vowels don't occur in dictionary words.) After that, we'll set the current character to this small vowel; in essence, it will act like a reg...
[ "Sets", "the", "currently", "active", "small", "vowel", "e", ".", "g", ".", "ァ", "." ]
train
https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/converter.py#L553-L633
msikma/kanaconv
kanaconv/converter.py
KanaConv._postprocess_output
def _postprocess_output(self, output): ''' Performs the last modifications before the output is returned. ''' # Replace long vowels with circumflex characters. if self.vowel_style == CIRCUMFLEX_STYLE: try: output = output.translate(vowels_to_circumflex...
python
def _postprocess_output(self, output): ''' Performs the last modifications before the output is returned. ''' # Replace long vowels with circumflex characters. if self.vowel_style == CIRCUMFLEX_STYLE: try: output = output.translate(vowels_to_circumflex...
[ "def", "_postprocess_output", "(", "self", ",", "output", ")", ":", "# Replace long vowels with circumflex characters.", "if", "self", ".", "vowel_style", "==", "CIRCUMFLEX_STYLE", ":", "try", ":", "output", "=", "output", ".", "translate", "(", "vowels_to_circumflexe...
Performs the last modifications before the output is returned.
[ "Performs", "the", "last", "modifications", "before", "the", "output", "is", "returned", "." ]
train
https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/converter.py#L666-L683
msikma/kanaconv
kanaconv/converter.py
KanaConv._flush_stack
def _flush_stack(self): ''' Returns the final output and resets the machine's state. ''' output = self._postprocess_output(''.join(self.stack)) self._clear_char() self._empty_stack() if not PYTHON_2: return output else: return unic...
python
def _flush_stack(self): ''' Returns the final output and resets the machine's state. ''' output = self._postprocess_output(''.join(self.stack)) self._clear_char() self._empty_stack() if not PYTHON_2: return output else: return unic...
[ "def", "_flush_stack", "(", "self", ")", ":", "output", "=", "self", ".", "_postprocess_output", "(", "''", ".", "join", "(", "self", ".", "stack", ")", ")", "self", ".", "_clear_char", "(", ")", "self", ".", "_empty_stack", "(", ")", "if", "not", "P...
Returns the final output and resets the machine's state.
[ "Returns", "the", "final", "output", "and", "resets", "the", "machine", "s", "state", "." ]
train
https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/converter.py#L685-L696
msikma/kanaconv
kanaconv/converter.py
KanaConv._preprocess_input
def _preprocess_input(self, input): ''' Preprocesses the input before it's split into a list. ''' if not re.search(preprocess_chars, input): # No characters that we need to preprocess, so continue without. return input input = self._add_punctuation_spacin...
python
def _preprocess_input(self, input): ''' Preprocesses the input before it's split into a list. ''' if not re.search(preprocess_chars, input): # No characters that we need to preprocess, so continue without. return input input = self._add_punctuation_spacin...
[ "def", "_preprocess_input", "(", "self", ",", "input", ")", ":", "if", "not", "re", ".", "search", "(", "preprocess_chars", ",", "input", ")", ":", "# No characters that we need to preprocess, so continue without.", "return", "input", "input", "=", "self", ".", "_...
Preprocesses the input before it's split into a list.
[ "Preprocesses", "the", "input", "before", "it", "s", "split", "into", "a", "list", "." ]
train
https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/converter.py#L698-L708
msikma/kanaconv
kanaconv/converter.py
KanaConv._preprocess_chars
def _preprocess_chars(self, chars): ''' Performs string preprocessing before the main conversion algorithm is used. Simple string replacements (for example, fullwidth rōmaji to regular rōmaji) are performed at this point. ''' chars = self._normalize_dakuten(chars) ...
python
def _preprocess_chars(self, chars): ''' Performs string preprocessing before the main conversion algorithm is used. Simple string replacements (for example, fullwidth rōmaji to regular rōmaji) are performed at this point. ''' chars = self._normalize_dakuten(chars) ...
[ "def", "_preprocess_chars", "(", "self", ",", "chars", ")", ":", "chars", "=", "self", ".", "_normalize_dakuten", "(", "chars", ")", "chars", "=", "self", ".", "_process_repeaters", "(", "chars", ")", "chars", "=", "self", ".", "_perform_replacements", "(", ...
Performs string preprocessing before the main conversion algorithm is used. Simple string replacements (for example, fullwidth rōmaji to regular rōmaji) are performed at this point.
[ "Performs", "string", "preprocessing", "before", "the", "main", "conversion", "algorithm", "is", "used", ".", "Simple", "string", "replacements", "(", "for", "example", "fullwidth", "rōmaji", "to", "regular", "rōmaji", ")", "are", "performed", "at", "this", "poi...
train
https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/converter.py#L710-L720
msikma/kanaconv
kanaconv/converter.py
KanaConv._add_punctuation_spacing
def _add_punctuation_spacing(self, input): ''' Adds additional spacing to punctuation characters. For example, this puts an extra space after a fullwidth full stop. ''' for replacement in punct_spacing: input = re.sub(replacement[0], replacement[1], input) re...
python
def _add_punctuation_spacing(self, input): ''' Adds additional spacing to punctuation characters. For example, this puts an extra space after a fullwidth full stop. ''' for replacement in punct_spacing: input = re.sub(replacement[0], replacement[1], input) re...
[ "def", "_add_punctuation_spacing", "(", "self", ",", "input", ")", ":", "for", "replacement", "in", "punct_spacing", ":", "input", "=", "re", ".", "sub", "(", "replacement", "[", "0", "]", ",", "replacement", "[", "1", "]", ",", "input", ")", "return", ...
Adds additional spacing to punctuation characters. For example, this puts an extra space after a fullwidth full stop.
[ "Adds", "additional", "spacing", "to", "punctuation", "characters", ".", "For", "example", "this", "puts", "an", "extra", "space", "after", "a", "fullwidth", "full", "stop", "." ]
train
https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/converter.py#L722-L730
msikma/kanaconv
kanaconv/converter.py
KanaConv._perform_replacements
def _perform_replacements(self, chars): ''' Performs simple key/value string replacements that require no logic. This is used to convert the fullwidth rōmaji, several ligatures, and the punctuation characters. ''' for n in range(len(chars)): char = chars[n] ...
python
def _perform_replacements(self, chars): ''' Performs simple key/value string replacements that require no logic. This is used to convert the fullwidth rōmaji, several ligatures, and the punctuation characters. ''' for n in range(len(chars)): char = chars[n] ...
[ "def", "_perform_replacements", "(", "self", ",", "chars", ")", ":", "for", "n", "in", "range", "(", "len", "(", "chars", ")", ")", ":", "char", "=", "chars", "[", "n", "]", "if", "char", "in", "repl", ":", "chars", "[", "n", "]", "=", "repl", ...
Performs simple key/value string replacements that require no logic. This is used to convert the fullwidth rōmaji, several ligatures, and the punctuation characters.
[ "Performs", "simple", "key", "/", "value", "string", "replacements", "that", "require", "no", "logic", ".", "This", "is", "used", "to", "convert", "the", "fullwidth", "rōmaji", "several", "ligatures", "and", "the", "punctuation", "characters", "." ]
train
https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/converter.py#L732-L746
msikma/kanaconv
kanaconv/converter.py
KanaConv._normalize_dakuten
def _normalize_dakuten(self, chars): ''' Replaces the dakuten and handakuten modifier character combinations with single characters. For example, か\u3099か becomes がけ, or は゜は becomes ぱは. ''' prev = None prev_n = None # Set all repeater characters to 0 init...
python
def _normalize_dakuten(self, chars): ''' Replaces the dakuten and handakuten modifier character combinations with single characters. For example, か\u3099か becomes がけ, or は゜は becomes ぱは. ''' prev = None prev_n = None # Set all repeater characters to 0 init...
[ "def", "_normalize_dakuten", "(", "self", ",", "chars", ")", ":", "prev", "=", "None", "prev_n", "=", "None", "# Set all repeater characters to 0 initially,", "# then go through the list and remove them all.", "for", "n", "in", "range", "(", "len", "(", "chars", ")", ...
Replaces the dakuten and handakuten modifier character combinations with single characters. For example, か\u3099か becomes がけ, or は゜は becomes ぱは.
[ "Replaces", "the", "dakuten", "and", "handakuten", "modifier", "character", "combinations", "with", "single", "characters", ".", "For", "example", "か", "\\", "u3099か", "becomes", "がけ", "or", "は゜は", "becomes", "ぱは", "." ]
train
https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/converter.py#L748-L777
msikma/kanaconv
kanaconv/converter.py
KanaConv._process_repeaters
def _process_repeaters(self, chars): ''' Replace all repeater characters (e.g. turn サヾエ into サザエ). ''' prev = None for n in range(len(chars)): char = chars[n] if char in rpts: # The character is a repeater. chars[n] = prev ...
python
def _process_repeaters(self, chars): ''' Replace all repeater characters (e.g. turn サヾエ into サザエ). ''' prev = None for n in range(len(chars)): char = chars[n] if char in rpts: # The character is a repeater. chars[n] = prev ...
[ "def", "_process_repeaters", "(", "self", ",", "chars", ")", ":", "prev", "=", "None", "for", "n", "in", "range", "(", "len", "(", "chars", ")", ")", ":", "char", "=", "chars", "[", "n", "]", "if", "char", "in", "rpts", ":", "# The character is a rep...
Replace all repeater characters (e.g. turn サヾエ into サザエ).
[ "Replace", "all", "repeater", "characters", "(", "e", ".", "g", ".", "turn", "サヾエ", "into", "サザエ", ")", "." ]
train
https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/converter.py#L779-L801
msikma/kanaconv
kanaconv/converter.py
KanaConv.to_romaji
def to_romaji(self, input): ''' Converts kana input to rōmaji and returns the result. ''' input = self._preprocess_input(input) # Preprocess the input, making string replacements where needed. chars = list(input) chars = self._preprocess_chars(chars) cha...
python
def to_romaji(self, input): ''' Converts kana input to rōmaji and returns the result. ''' input = self._preprocess_input(input) # Preprocess the input, making string replacements where needed. chars = list(input) chars = self._preprocess_chars(chars) cha...
[ "def", "to_romaji", "(", "self", ",", "input", ")", ":", "input", "=", "self", ".", "_preprocess_input", "(", "input", ")", "# Preprocess the input, making string replacements where needed.", "chars", "=", "list", "(", "input", ")", "chars", "=", "self", ".", "_...
Converts kana input to rōmaji and returns the result.
[ "Converts", "kana", "input", "to", "rōmaji", "and", "returns", "the", "result", "." ]
train
https://github.com/msikma/kanaconv/blob/194f142e616ab5dd6d13a687b96b9f8abd1b4ea8/kanaconv/converter.py#L803-L867
ff0000/scarlet
scarlet/cms/base_views.py
BaseView.get_render_data
def get_render_data(self, **kwargs): """ Because of the way mixin inheritance works we can't have a default implementation of get_context_data on the this class, so this calls that method if available and returns the resulting context. """ if hasattr(self,...
python
def get_render_data(self, **kwargs): """ Because of the way mixin inheritance works we can't have a default implementation of get_context_data on the this class, so this calls that method if available and returns the resulting context. """ if hasattr(self,...
[ "def", "get_render_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "if", "hasattr", "(", "self", ",", "'get_context_data'", ")", ":", "data", "=", "self", ".", "get_context_data", "(", "*", "*", "kwargs", ")", "else", ":", "data", "=", "kwargs",...
Because of the way mixin inheritance works we can't have a default implementation of get_context_data on the this class, so this calls that method if available and returns the resulting context.
[ "Because", "of", "the", "way", "mixin", "inheritance", "works", "we", "can", "t", "have", "a", "default", "implementation", "of", "get_context_data", "on", "the", "this", "class", "so", "this", "calls", "that", "method", "if", "available", "and", "returns", ...
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/base_views.py#L43-L55
ff0000/scarlet
scarlet/cms/base_views.py
BaseView.render
def render(self, request, collect_render_data=True, **kwargs): """ Render this view. This will call the render method on the render class specified. :param request: The request object :param collect_render_data: If True we will call \ the get_render_data method to pass a...
python
def render(self, request, collect_render_data=True, **kwargs): """ Render this view. This will call the render method on the render class specified. :param request: The request object :param collect_render_data: If True we will call \ the get_render_data method to pass a...
[ "def", "render", "(", "self", ",", "request", ",", "collect_render_data", "=", "True", ",", "*", "*", "kwargs", ")", ":", "assert", "self", ".", "render_type", "in", "self", ".", "renders", "render", "=", "self", ".", "renders", "[", "self", ".", "rend...
Render this view. This will call the render method on the render class specified. :param request: The request object :param collect_render_data: If True we will call \ the get_render_data method to pass a complete context \ to the renderer. :param kwargs: Any other keywo...
[ "Render", "this", "view", ".", "This", "will", "call", "the", "render", "method", "on", "the", "render", "class", "specified", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/base_views.py#L57-L74
ff0000/scarlet
scarlet/cms/base_views.py
SiteView.as_string
def as_string(cls, **initkwargs): """ Similar to the as_view classmethod except this method will render this view as a string. When rendering a view this way the request will always be routed to the get method. The default render_type is 'string' unless you specify someth...
python
def as_string(cls, **initkwargs): """ Similar to the as_view classmethod except this method will render this view as a string. When rendering a view this way the request will always be routed to the get method. The default render_type is 'string' unless you specify someth...
[ "def", "as_string", "(", "cls", ",", "*", "*", "initkwargs", ")", ":", "if", "not", "'render_type'", "in", "initkwargs", ":", "initkwargs", "[", "'render_type'", "]", "=", "'string'", "for", "key", "in", "initkwargs", ":", "if", "key", "in", "cls", ".", ...
Similar to the as_view classmethod except this method will render this view as a string. When rendering a view this way the request will always be routed to the get method. The default render_type is 'string' unless you specify something else. If you provide your own render_type be sure ...
[ "Similar", "to", "the", "as_view", "classmethod", "except", "this", "method", "will", "render", "this", "view", "as", "a", "string", ".", "When", "rendering", "a", "view", "this", "way", "the", "request", "will", "always", "be", "routed", "to", "the", "get...
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/base_views.py#L87-L122
ff0000/scarlet
scarlet/cms/base_views.py
CMSView.get_tags
def get_tags(self, view_object=None): """ This method return a list of tags to use in the template :return: list of tags """ tags = [force_unicode(self.bundle.get_title())] back_bundle = self.get_back_bundle() if back_bundle and back_bundle != self.bundle: ...
python
def get_tags(self, view_object=None): """ This method return a list of tags to use in the template :return: list of tags """ tags = [force_unicode(self.bundle.get_title())] back_bundle = self.get_back_bundle() if back_bundle and back_bundle != self.bundle: ...
[ "def", "get_tags", "(", "self", ",", "view_object", "=", "None", ")", ":", "tags", "=", "[", "force_unicode", "(", "self", ".", "bundle", ".", "get_title", "(", ")", ")", "]", "back_bundle", "=", "self", ".", "get_back_bundle", "(", ")", "if", "back_bu...
This method return a list of tags to use in the template :return: list of tags
[ "This", "method", "return", "a", "list", "of", "tags", "to", "use", "in", "the", "template", ":", "return", ":", "list", "of", "tags" ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/base_views.py#L202-L214
ff0000/scarlet
scarlet/cms/base_views.py
CMSView.get_render_data
def get_render_data(self, **kwargs): """ Returns all data that should be passed to the renderer. By default adds the following arguments: * **bundle** - The bundle that is attached to this view instance. * **url_params** - The url keyword arguments. i.e.: self.kwargs. * ...
python
def get_render_data(self, **kwargs): """ Returns all data that should be passed to the renderer. By default adds the following arguments: * **bundle** - The bundle that is attached to this view instance. * **url_params** - The url keyword arguments. i.e.: self.kwargs. * ...
[ "def", "get_render_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "obj", "=", "getattr", "(", "self", ",", "'object'", ",", "None", ")", "data", "=", "dict", "(", "self", ".", "extra_render_data", ")", "data", ".", "update", "(", "kwargs", ")...
Returns all data that should be passed to the renderer. By default adds the following arguments: * **bundle** - The bundle that is attached to this view instance. * **url_params** - The url keyword arguments. i.e.: self.kwargs. * **user** - The user attached to this request. * *...
[ "Returns", "all", "data", "that", "should", "be", "passed", "to", "the", "renderer", ".", "By", "default", "adds", "the", "following", "arguments", ":" ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/base_views.py#L226-L265
ff0000/scarlet
scarlet/cms/base_views.py
CMSView.can_view
def can_view(self, user): """ Returns True if user has permission to render this view. At minimum this requires an active staff user. If the required_groups attribute is not empty then the user must be a member of at least one of those groups. If there are no required groups set...
python
def can_view(self, user): """ Returns True if user has permission to render this view. At minimum this requires an active staff user. If the required_groups attribute is not empty then the user must be a member of at least one of those groups. If there are no required groups set...
[ "def", "can_view", "(", "self", ",", "user", ")", ":", "if", "user", ".", "is_staff", "and", "user", ".", "is_active", ":", "if", "user", ".", "is_superuser", ":", "return", "True", "elif", "self", ".", "required_groups", ":", "return", "self", ".", "_...
Returns True if user has permission to render this view. At minimum this requires an active staff user. If the required_groups attribute is not empty then the user must be a member of at least one of those groups. If there are no required groups set for the view but required groups are ...
[ "Returns", "True", "if", "user", "has", "permission", "to", "render", "this", "view", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/base_views.py#L277-L299
ff0000/scarlet
scarlet/cms/base_views.py
CMSView.get_url_kwargs
def get_url_kwargs(self, request_kwargs=None, **kwargs): """ Get the kwargs needed to reverse this url. :param request_kwargs: The kwargs from the current request. \ These keyword arguments are only retained if they are present \ in this bundle's known url_parameters. :p...
python
def get_url_kwargs(self, request_kwargs=None, **kwargs): """ Get the kwargs needed to reverse this url. :param request_kwargs: The kwargs from the current request. \ These keyword arguments are only retained if they are present \ in this bundle's known url_parameters. :p...
[ "def", "get_url_kwargs", "(", "self", ",", "request_kwargs", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "request_kwargs", ":", "request_kwargs", "=", "getattr", "(", "self", ",", "'kwargs'", ",", "{", "}", ")", "for", "k", "in", "self...
Get the kwargs needed to reverse this url. :param request_kwargs: The kwargs from the current request. \ These keyword arguments are only retained if they are present \ in this bundle's known url_parameters. :param kwargs: Keyword arguments that will always be kept.
[ "Get", "the", "kwargs", "needed", "to", "reverse", "this", "url", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/base_views.py#L301-L317
ff0000/scarlet
scarlet/cms/base_views.py
CMSView.customize_form_widgets
def customize_form_widgets(self, form_class, fields=None): """ Hook for customizing widgets for a form_class. This is needed for forms that specify their own fields causing the default db_field callback to not be run for that field. Default implementation checks for APIModelChoi...
python
def customize_form_widgets(self, form_class, fields=None): """ Hook for customizing widgets for a form_class. This is needed for forms that specify their own fields causing the default db_field callback to not be run for that field. Default implementation checks for APIModelChoi...
[ "def", "customize_form_widgets", "(", "self", ",", "form_class", ",", "fields", "=", "None", ")", ":", "attrs", "=", "{", "}", "if", "fields", ":", "fields", "=", "set", "(", "fields", ")", "for", "k", ",", "f", "in", "form_class", ".", "base_fields", ...
Hook for customizing widgets for a form_class. This is needed for forms that specify their own fields causing the default db_field callback to not be run for that field. Default implementation checks for APIModelChoiceWidgets or APIManyChoiceWidgets and runs the update_links method ...
[ "Hook", "for", "customizing", "widgets", "for", "a", "form_class", ".", "This", "is", "needed", "for", "forms", "that", "specify", "their", "own", "fields", "causing", "the", "default", "db_field", "callback", "to", "not", "be", "run", "for", "that", "field"...
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/base_views.py#L319-L349
ff0000/scarlet
scarlet/cms/base_views.py
CMSView.dispatch
def dispatch(self, request, *args, **kwargs): """ Overrides the custom dispatch method to raise a Http404 if the current user does not have view permissions. """ self.request = request self.args = args self.kwargs = kwargs if not self.can_view(request.use...
python
def dispatch(self, request, *args, **kwargs): """ Overrides the custom dispatch method to raise a Http404 if the current user does not have view permissions. """ self.request = request self.args = args self.kwargs = kwargs if not self.can_view(request.use...
[ "def", "dispatch", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "request", "=", "request", "self", ".", "args", "=", "args", "self", ".", "kwargs", "=", "kwargs", "if", "not", "self", ".", "can_view...
Overrides the custom dispatch method to raise a Http404 if the current user does not have view permissions.
[ "Overrides", "the", "custom", "dispatch", "method", "to", "raise", "a", "Http404", "if", "the", "current", "user", "does", "not", "have", "view", "permissions", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/base_views.py#L352-L364
ff0000/scarlet
scarlet/cms/base_views.py
ModelCMSMixin.formfield_for_dbfield
def formfield_for_dbfield(self, db_field, **kwargs): """ Hook for specifying the form Field instance for a given database Field instance. If kwargs are given, they're passed to the form Field's constructor. Default implementation uses the overrides returned by `get_formf...
python
def formfield_for_dbfield(self, db_field, **kwargs): """ Hook for specifying the form Field instance for a given database Field instance. If kwargs are given, they're passed to the form Field's constructor. Default implementation uses the overrides returned by `get_formf...
[ "def", "formfield_for_dbfield", "(", "self", ",", "db_field", ",", "*", "*", "kwargs", ")", ":", "overides", "=", "self", ".", "get_formfield_overrides", "(", ")", "# If we've got overrides for the formfield defined, use 'em. **kwargs", "# passed to formfield_for_dbfield over...
Hook for specifying the form Field instance for a given database Field instance. If kwargs are given, they're passed to the form Field's constructor. Default implementation uses the overrides returned by `get_formfield_overrides`. If a widget is an instance of APIChoiceWidget th...
[ "Hook", "for", "specifying", "the", "form", "Field", "instance", "for", "a", "given", "database", "Field", "instance", ".", "If", "kwargs", "are", "given", "they", "re", "passed", "to", "the", "form", "Field", "s", "constructor", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/base_views.py#L409-L467
ff0000/scarlet
scarlet/cms/base_views.py
ModelCMSMixin.log_action
def log_action(self, instance, action, action_date=None, url="", update_parent=True): """ Store an action in the database using the CMSLog model. The following attributes are calculated and set on the log entry: * **model_repr** - A unicode representation of the inst...
python
def log_action(self, instance, action, action_date=None, url="", update_parent=True): """ Store an action in the database using the CMSLog model. The following attributes are calculated and set on the log entry: * **model_repr** - A unicode representation of the inst...
[ "def", "log_action", "(", "self", ",", "instance", ",", "action", ",", "action_date", "=", "None", ",", "url", "=", "\"\"", ",", "update_parent", "=", "True", ")", ":", "section", "=", "None", "if", "self", ".", "bundle", ":", "bundle", "=", "self", ...
Store an action in the database using the CMSLog model. The following attributes are calculated and set on the log entry: * **model_repr** - A unicode representation of the instance. * **object_repr** - The verbose_name of the instance model class. * **section** - The name of ancesto...
[ "Store", "an", "action", "in", "the", "database", "using", "the", "CMSLog", "model", ".", "The", "following", "attributes", "are", "calculated", "and", "set", "on", "the", "log", "entry", ":" ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/base_views.py#L469-L528
ff0000/scarlet
scarlet/cms/base_views.py
ModelCMSMixin.get_filter
def get_filter(self, **filter_kwargs): """ Returns a list of Q objects that can be passed to an queryset for filtering. Default implementation returns a Q object for `base_filter_kwargs` and any passed in keyword arguments. """ filter_kwargs.update(self.b...
python
def get_filter(self, **filter_kwargs): """ Returns a list of Q objects that can be passed to an queryset for filtering. Default implementation returns a Q object for `base_filter_kwargs` and any passed in keyword arguments. """ filter_kwargs.update(self.b...
[ "def", "get_filter", "(", "self", ",", "*", "*", "filter_kwargs", ")", ":", "filter_kwargs", ".", "update", "(", "self", ".", "base_filter_kwargs", ")", "if", "filter_kwargs", ":", "return", "[", "models", ".", "Q", "(", "*", "*", "filter_kwargs", ")", "...
Returns a list of Q objects that can be passed to an queryset for filtering. Default implementation returns a Q object for `base_filter_kwargs` and any passed in keyword arguments.
[ "Returns", "a", "list", "of", "Q", "objects", "that", "can", "be", "passed", "to", "an", "queryset", "for", "filtering", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/base_views.py#L530-L542
ff0000/scarlet
scarlet/cms/base_views.py
ModelCMSMixin.get_queryset
def get_queryset(self, **filter_kwargs): """ Get the list of items for this view. This will call the `get_parent_object` method before doing anything else to ensure that a valid parent object is present. If a parent_object is returned it gets set to `self.parent_object`. ...
python
def get_queryset(self, **filter_kwargs): """ Get the list of items for this view. This will call the `get_parent_object` method before doing anything else to ensure that a valid parent object is present. If a parent_object is returned it gets set to `self.parent_object`. ...
[ "def", "get_queryset", "(", "self", ",", "*", "*", "filter_kwargs", ")", ":", "self", ".", "parent_object", "=", "self", ".", "get_parent_object", "(", ")", "if", "self", ".", "queryset", "is", "not", "None", ":", "queryset", "=", "self", ".", "queryset"...
Get the list of items for this view. This will call the `get_parent_object` method before doing anything else to ensure that a valid parent object is present. If a parent_object is returned it gets set to `self.parent_object`. If a queryset has been set then that queryset will b...
[ "Get", "the", "list", "of", "items", "for", "this", "view", ".", "This", "will", "call", "the", "get_parent_object", "method", "before", "doing", "anything", "else", "to", "ensure", "that", "a", "valid", "parent", "object", "is", "present", ".", "If", "a",...
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/base_views.py#L544-L577
ff0000/scarlet
scarlet/cms/base_views.py
ModelCMSMixin.get_parent_object
def get_parent_object(self): """ Lookup a parent object. If parent_field is None this will return None. Otherwise this will try to return that object. The filter arguments are found by using the known url parameters of the bundle, finding the value in the url keyword ...
python
def get_parent_object(self): """ Lookup a parent object. If parent_field is None this will return None. Otherwise this will try to return that object. The filter arguments are found by using the known url parameters of the bundle, finding the value in the url keyword ...
[ "def", "get_parent_object", "(", "self", ")", ":", "if", "self", ".", "parent_field", ":", "# Get the model we are querying on", "if", "getattr", "(", "self", ".", "model", ".", "_meta", ",", "'init_name_map'", ",", "None", ")", ":", "# pre-django-1.8", "cache",...
Lookup a parent object. If parent_field is None this will return None. Otherwise this will try to return that object. The filter arguments are found by using the known url parameters of the bundle, finding the value in the url keyword arguments and matching them with the argumen...
[ "Lookup", "a", "parent", "object", ".", "If", "parent_field", "is", "None", "this", "will", "return", "None", ".", "Otherwise", "this", "will", "try", "to", "return", "that", "object", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/base_views.py#L579-L696
ff0000/scarlet
scarlet/cms/base_views.py
ModelCMSView.write_message
def write_message(self, status=messages.INFO, message=None): """ Writes a message to django's messaging framework and returns the written message. :param status: The message status level. Defaults to \ messages.INFO. :param message: The message to write. If not given, \ ...
python
def write_message(self, status=messages.INFO, message=None): """ Writes a message to django's messaging framework and returns the written message. :param status: The message status level. Defaults to \ messages.INFO. :param message: The message to write. If not given, \ ...
[ "def", "write_message", "(", "self", ",", "status", "=", "messages", ".", "INFO", ",", "message", "=", "None", ")", ":", "if", "not", "message", ":", "message", "=", "u\"%s saved\"", "%", "self", ".", "object", "messages", ".", "add_message", "(", "self"...
Writes a message to django's messaging framework and returns the written message. :param status: The message status level. Defaults to \ messages.INFO. :param message: The message to write. If not given, \ defaults to appending 'saved' to the unicode representation \ of ...
[ "Writes", "a", "message", "to", "django", "s", "messaging", "framework", "and", "returns", "the", "written", "message", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/base_views.py#L715-L729
ff0000/scarlet
scarlet/cms/base_views.py
ModelCMSView.get_url_kwargs
def get_url_kwargs(self, request_kwargs=None, **kwargs): """ If request_kwargs is not specified, self.kwargs is used instead. If 'object' is one of the kwargs passed. Replaces it with the value of 'self.slug_field' on the given object. """ if not request_kwargs: ...
python
def get_url_kwargs(self, request_kwargs=None, **kwargs): """ If request_kwargs is not specified, self.kwargs is used instead. If 'object' is one of the kwargs passed. Replaces it with the value of 'self.slug_field' on the given object. """ if not request_kwargs: ...
[ "def", "get_url_kwargs", "(", "self", ",", "request_kwargs", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "request_kwargs", ":", "request_kwargs", "=", "getattr", "(", "self", ",", "'kwargs'", ",", "{", "}", ")", "kwargs", "=", "super", ...
If request_kwargs is not specified, self.kwargs is used instead. If 'object' is one of the kwargs passed. Replaces it with the value of 'self.slug_field' on the given object.
[ "If", "request_kwargs", "is", "not", "specified", "self", ".", "kwargs", "is", "used", "instead", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/base_views.py#L731-L750
ff0000/scarlet
scarlet/cms/base_views.py
ModelCMSView.get_render_data
def get_render_data(self, **kwargs): """ Adds the model_name to the context, then calls super. """ kwargs['model_name'] = self.model_name kwargs['model_name_plural'] = self.model_name_plural return super(ModelCMSView, self).get_render_data(**kwargs)
python
def get_render_data(self, **kwargs): """ Adds the model_name to the context, then calls super. """ kwargs['model_name'] = self.model_name kwargs['model_name_plural'] = self.model_name_plural return super(ModelCMSView, self).get_render_data(**kwargs)
[ "def", "get_render_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "'model_name'", "]", "=", "self", ".", "model_name", "kwargs", "[", "'model_name_plural'", "]", "=", "self", ".", "model_name_plural", "return", "super", "(", "ModelCMSV...
Adds the model_name to the context, then calls super.
[ "Adds", "the", "model_name", "to", "the", "context", "then", "calls", "super", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/base_views.py#L775-L781
ff0000/scarlet
scarlet/cms/list.py
ListView.formfield_for_dbfield
def formfield_for_dbfield(self, db_field, **kwargs): """ Same as parent but sets the widget for any OrderFields to HiddenTextInput. """ if isinstance(db_field, fields.OrderField): kwargs['widget'] = widgets.HiddenTextInput return super(ListView, self).formfie...
python
def formfield_for_dbfield(self, db_field, **kwargs): """ Same as parent but sets the widget for any OrderFields to HiddenTextInput. """ if isinstance(db_field, fields.OrderField): kwargs['widget'] = widgets.HiddenTextInput return super(ListView, self).formfie...
[ "def", "formfield_for_dbfield", "(", "self", ",", "db_field", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "db_field", ",", "fields", ".", "OrderField", ")", ":", "kwargs", "[", "'widget'", "]", "=", "widgets", ".", "HiddenTextInput", "retur...
Same as parent but sets the widget for any OrderFields to HiddenTextInput.
[ "Same", "as", "parent", "but", "sets", "the", "widget", "for", "any", "OrderFields", "to", "HiddenTextInput", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/list.py#L81-L89
ff0000/scarlet
scarlet/cms/list.py
ListView.get_filter_form
def get_filter_form(self, **kwargs): """ If there is a filter_form, initializes that form with the contents of request.GET and returns it. """ form = None if self.filter_form: form = self.filter_form(self.request.GET) elif self.model and hasat...
python
def get_filter_form(self, **kwargs): """ If there is a filter_form, initializes that form with the contents of request.GET and returns it. """ form = None if self.filter_form: form = self.filter_form(self.request.GET) elif self.model and hasat...
[ "def", "get_filter_form", "(", "self", ",", "*", "*", "kwargs", ")", ":", "form", "=", "None", "if", "self", ".", "filter_form", ":", "form", "=", "self", ".", "filter_form", "(", "self", ".", "request", ".", "GET", ")", "elif", "self", ".", "model",...
If there is a filter_form, initializes that form with the contents of request.GET and returns it.
[ "If", "there", "is", "a", "filter_form", "initializes", "that", "form", "with", "the", "contents", "of", "request", ".", "GET", "and", "returns", "it", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/list.py#L112-L124
ff0000/scarlet
scarlet/cms/list.py
ListView.get_filter
def get_filter(self, **filter_kwargs): """ Combines the Q objects returned by a valid filter form with any other arguments and returns a list of Q objects that can be passed to a queryset. """ q_objects = super(ListView, self).get_filter(**filter_kwargs) ...
python
def get_filter(self, **filter_kwargs): """ Combines the Q objects returned by a valid filter form with any other arguments and returns a list of Q objects that can be passed to a queryset. """ q_objects = super(ListView, self).get_filter(**filter_kwargs) ...
[ "def", "get_filter", "(", "self", ",", "*", "*", "filter_kwargs", ")", ":", "q_objects", "=", "super", "(", "ListView", ",", "self", ")", ".", "get_filter", "(", "*", "*", "filter_kwargs", ")", "form", "=", "self", ".", "get_filter_form", "(", ")", "if...
Combines the Q objects returned by a valid filter form with any other arguments and returns a list of Q objects that can be passed to a queryset.
[ "Combines", "the", "Q", "objects", "returned", "by", "a", "valid", "filter", "form", "with", "any", "other", "arguments", "and", "returns", "a", "list", "of", "Q", "objects", "that", "can", "be", "passed", "to", "a", "queryset", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/list.py#L126-L139
ff0000/scarlet
scarlet/cms/list.py
ListView.get_formset_form_class
def get_formset_form_class(self): """ Returns the form class for use in the formset. If a form_class attribute or change_fields is provided then a form will be constructed with that. Otherwise None is returned. """ if self.form_class or self.change_fields: ...
python
def get_formset_form_class(self): """ Returns the form class for use in the formset. If a form_class attribute or change_fields is provided then a form will be constructed with that. Otherwise None is returned. """ if self.form_class or self.change_fields: ...
[ "def", "get_formset_form_class", "(", "self", ")", ":", "if", "self", ".", "form_class", "or", "self", ".", "change_fields", ":", "params", "=", "{", "'formfield_callback'", ":", "self", ".", "formfield_for_dbfield", "}", "if", "self", ".", "form_class", ":", ...
Returns the form class for use in the formset. If a form_class attribute or change_fields is provided then a form will be constructed with that. Otherwise None is returned.
[ "Returns", "the", "form", "class", "for", "use", "in", "the", "formset", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/list.py#L141-L157
ff0000/scarlet
scarlet/cms/list.py
ListView.get_formset_class
def get_formset_class(self, **kwargs): """ Returns the formset for the queryset, if a form class is available. """ form_class = self.get_formset_form_class() if form_class: kwargs['formfield_callback'] = self.formfield_for_dbfield return model_form...
python
def get_formset_class(self, **kwargs): """ Returns the formset for the queryset, if a form class is available. """ form_class = self.get_formset_form_class() if form_class: kwargs['formfield_callback'] = self.formfield_for_dbfield return model_form...
[ "def", "get_formset_class", "(", "self", ",", "*", "*", "kwargs", ")", ":", "form_class", "=", "self", ".", "get_formset_form_class", "(", ")", "if", "form_class", ":", "kwargs", "[", "'formfield_callback'", "]", "=", "self", ".", "formfield_for_dbfield", "ret...
Returns the formset for the queryset, if a form class is available.
[ "Returns", "the", "formset", "for", "the", "queryset", "if", "a", "form", "class", "is", "available", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/list.py#L159-L169
ff0000/scarlet
scarlet/cms/list.py
ListView.get_formset
def get_formset(self, data=None, queryset=None): """ Returns an instantiated FormSet if available. If `self.can_submit` is False then no formset is returned. """ if not self.can_submit: return None FormSet = self.get_formset_class() if queryse...
python
def get_formset(self, data=None, queryset=None): """ Returns an instantiated FormSet if available. If `self.can_submit` is False then no formset is returned. """ if not self.can_submit: return None FormSet = self.get_formset_class() if queryse...
[ "def", "get_formset", "(", "self", ",", "data", "=", "None", ",", "queryset", "=", "None", ")", ":", "if", "not", "self", ".", "can_submit", ":", "return", "None", "FormSet", "=", "self", ".", "get_formset_class", "(", ")", "if", "queryset", "is", "Non...
Returns an instantiated FormSet if available. If `self.can_submit` is False then no formset is returned.
[ "Returns", "an", "instantiated", "FormSet", "if", "available", ".", "If", "self", ".", "can_submit", "is", "False", "then", "no", "formset", "is", "returned", "." ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/list.py#L184-L200
ff0000/scarlet
scarlet/cms/list.py
ListView.get_visible_fields
def get_visible_fields(self, formset): """ Returns a list of visible fields. This are all the fields in `self.display_fields` plus any visible fields in the given formset minus any hidden fields in the formset. """ visible_fields = list(self.display_fields) ...
python
def get_visible_fields(self, formset): """ Returns a list of visible fields. This are all the fields in `self.display_fields` plus any visible fields in the given formset minus any hidden fields in the formset. """ visible_fields = list(self.display_fields) ...
[ "def", "get_visible_fields", "(", "self", ",", "formset", ")", ":", "visible_fields", "=", "list", "(", "self", ".", "display_fields", ")", "if", "formset", ":", "for", "x", "in", "formset", ".", "empty_form", ".", "visible_fields", "(", ")", ":", "if", ...
Returns a list of visible fields. This are all the fields in `self.display_fields` plus any visible fields in the given formset minus any hidden fields in the formset.
[ "Returns", "a", "list", "of", "visible", "fields", ".", "This", "are", "all", "the", "fields", "in", "self", ".", "display_fields", "plus", "any", "visible", "fields", "in", "the", "given", "formset", "minus", "any", "hidden", "fields", "in", "the", "forms...
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/list.py#L202-L220
ff0000/scarlet
scarlet/cms/list.py
ListView.get_list_data
def get_list_data(self, request, **kwargs): """ Returns the data needed for displaying the list. Returns a dictionary that should be treating as context with the following arguments: * **list** - The list of data to be displayed. This is \ an instance of a wrapper class ...
python
def get_list_data(self, request, **kwargs): """ Returns the data needed for displaying the list. Returns a dictionary that should be treating as context with the following arguments: * **list** - The list of data to be displayed. This is \ an instance of a wrapper class ...
[ "def", "get_list_data", "(", "self", ",", "request", ",", "*", "*", "kwargs", ")", ":", "self", ".", "object_list", "=", "self", ".", "get_queryset", "(", ")", "self", ".", "_verify_list", "(", ")", "sort_field", "=", "None", "order_type", "=", "None", ...
Returns the data needed for displaying the list. Returns a dictionary that should be treating as context with the following arguments: * **list** - The list of data to be displayed. This is \ an instance of a wrapper class that combines the queryset \ and formset and provides lo...
[ "Returns", "the", "data", "needed", "for", "displaying", "the", "list", ".", "Returns", "a", "dictionary", "that", "should", "be", "treating", "as", "context", "with", "the", "following", "arguments", ":" ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/list.py#L271-L334
ff0000/scarlet
scarlet/cms/list.py
ListView.get_context_data
def get_context_data(self, **kwargs): """ Get the context for this view. Adds the following values: * **query_string** - The querystring minus the current page. * **action_links** - The results of the `get_actions` method. """ origin_qs = self._get_query_string(self.req...
python
def get_context_data(self, **kwargs): """ Get the context for this view. Adds the following values: * **query_string** - The querystring minus the current page. * **action_links** - The results of the `get_actions` method. """ origin_qs = self._get_query_string(self.req...
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "origin_qs", "=", "self", ".", "_get_query_string", "(", "self", ".", "request", ",", "False", ")", "context", "=", "{", "'query_string'", ":", "self", ".", "_get_query_string", "("...
Get the context for this view. Adds the following values: * **query_string** - The querystring minus the current page. * **action_links** - The results of the `get_actions` method.
[ "Get", "the", "context", "for", "this", "view", ".", "Adds", "the", "following", "values", ":" ]
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/list.py#L336-L353
ff0000/scarlet
scarlet/cms/list.py
ListView.get
def get(self, request, *args, **kwargs): """ Method for handling GET requests. If there is a GET parameter type=choice, then the render_type will be set to 'choices' to return a JSON version of this list. Calls `render` with the data from the `get_list_data` method as con...
python
def get(self, request, *args, **kwargs): """ Method for handling GET requests. If there is a GET parameter type=choice, then the render_type will be set to 'choices' to return a JSON version of this list. Calls `render` with the data from the `get_list_data` method as con...
[ "def", "get", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "request", ".", "GET", ".", "get", "(", "'type'", ")", "==", "'choices'", ":", "self", ".", "render_type", "=", "'choices'", "self", ".", "can_sub...
Method for handling GET requests. If there is a GET parameter type=choice, then the render_type will be set to 'choices' to return a JSON version of this list. Calls `render` with the data from the `get_list_data` method as context.
[ "Method", "for", "handling", "GET", "requests", ".", "If", "there", "is", "a", "GET", "parameter", "type", "=", "choice", "then", "the", "render_type", "will", "be", "set", "to", "choices", "to", "return", "a", "JSON", "version", "of", "this", "list", "....
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/list.py#L355-L369
ff0000/scarlet
scarlet/cms/list.py
ListView.post
def post(self, request, *args, **kwargs): """ Method for handling POST requests. If the formset is valid this will loop through the formset and save each form. A log is generated for each save. The user is notified of the total number of changes with a message. Re...
python
def post(self, request, *args, **kwargs): """ Method for handling POST requests. If the formset is valid this will loop through the formset and save each form. A log is generated for each save. The user is notified of the total number of changes with a message. Re...
[ "def", "post", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "msg", "=", "None", "action", "=", "request", ".", "POST", ".", "get", "(", "'actions'", ",", "None", ")", "selected", "=", "request", ".", "POST", "...
Method for handling POST requests. If the formset is valid this will loop through the formset and save each form. A log is generated for each save. The user is notified of the total number of changes with a message. Returns a 'render redirect' to the current url. ...
[ "Method", "for", "handling", "POST", "requests", ".", "If", "the", "formset", "is", "valid", "this", "will", "loop", "through", "the", "formset", "and", "save", "each", "form", ".", "A", "log", "is", "generated", "for", "each", "save", ".", "The", "user"...
train
https://github.com/ff0000/scarlet/blob/6c37befd810916a2d7ffff2cdb2dab57bcb6d12e/scarlet/cms/list.py#L371-L432
kkujawinski/git-pre-push-hook
src/git_pre_push_hook/engine.py
BranchChanges.get_user_modified_lines
def get_user_modified_lines(self): """ Output: {file_path: [(line_a_start, line_a_end), (line_b_start, line_b_end)]} Lines ranges are sorted and not overlapping """ # I assume that git diff: # - doesn't mix diffs from different files, # - diffs are not overlappin...
python
def get_user_modified_lines(self): """ Output: {file_path: [(line_a_start, line_a_end), (line_b_start, line_b_end)]} Lines ranges are sorted and not overlapping """ # I assume that git diff: # - doesn't mix diffs from different files, # - diffs are not overlappin...
[ "def", "get_user_modified_lines", "(", "self", ")", ":", "# I assume that git diff:", "# - doesn't mix diffs from different files,", "# - diffs are not overlapping", "# - diffs are sorted based on line numbers", "output", "=", "{", "}", "FILE_NAME_RE", "=", "r'^\\+\\+\\+ (.+)$'", "...
Output: {file_path: [(line_a_start, line_a_end), (line_b_start, line_b_end)]} Lines ranges are sorted and not overlapping
[ "Output", ":", "{", "file_path", ":", "[", "(", "line_a_start", "line_a_end", ")", "(", "line_b_start", "line_b_end", ")", "]", "}" ]
train
https://github.com/kkujawinski/git-pre-push-hook/blob/b62f4199150de2d6ec3f6f383ad69b0dddf9948d/src/git_pre_push_hook/engine.py#L103-L136
kkujawinski/git-pre-push-hook
src/git_pre_push_hook/engine.py
BranchChanges.prepare_files
def prepare_files(self, target_dir): """ Proper version of file needs to be moved to external directory. Because: 1. local files can differ from commited, 2. we can push man branches """ diff_names = self.git_wrapper.get_diff_names(self.remote_sha1, self.local_sha1) files...
python
def prepare_files(self, target_dir): """ Proper version of file needs to be moved to external directory. Because: 1. local files can differ from commited, 2. we can push man branches """ diff_names = self.git_wrapper.get_diff_names(self.remote_sha1, self.local_sha1) files...
[ "def", "prepare_files", "(", "self", ",", "target_dir", ")", ":", "diff_names", "=", "self", ".", "git_wrapper", ".", "get_diff_names", "(", "self", ".", "remote_sha1", ",", "self", ".", "local_sha1", ")", "files_modified", "=", "diff_names", ".", "split", "...
Proper version of file needs to be moved to external directory. Because: 1. local files can differ from commited, 2. we can push man branches
[ "Proper", "version", "of", "file", "needs", "to", "be", "moved", "to", "external", "directory", ".", "Because", ":", "1", ".", "local", "files", "can", "differ", "from", "commited", "2", ".", "we", "can", "push", "man", "branches" ]
train
https://github.com/kkujawinski/git-pre-push-hook/blob/b62f4199150de2d6ec3f6f383ad69b0dddf9948d/src/git_pre_push_hook/engine.py#L138-L159
marvinpinto/charlesbot
charlesbot/plugins/ping_plugin.py
Ping.schedule_ping_frequency
def schedule_ping_frequency(self): # pragma: no cover "Send a ping message to slack every 20 seconds" ping = crontab('* * * * * */20', func=self.send_ping, start=False) ping.start()
python
def schedule_ping_frequency(self): # pragma: no cover "Send a ping message to slack every 20 seconds" ping = crontab('* * * * * */20', func=self.send_ping, start=False) ping.start()
[ "def", "schedule_ping_frequency", "(", "self", ")", ":", "# pragma: no cover", "ping", "=", "crontab", "(", "'* * * * * */20'", ",", "func", "=", "self", ".", "send_ping", ",", "start", "=", "False", ")", "ping", ".", "start", "(", ")" ]
Send a ping message to slack every 20 seconds
[ "Send", "a", "ping", "message", "to", "slack", "every", "20", "seconds" ]
train
https://github.com/marvinpinto/charlesbot/blob/4bbc0de42313ea8aaaa8d0d36ff3e717575117b3/charlesbot/plugins/ping_plugin.py#L20-L23
klahnakoski/pyLibrary
mo_threads/threads.py
stop_main_thread
def stop_main_thread(*args): """ CLEAN OF ALL THREADS CREATED WITH THIS LIBRARY """ try: if len(args) and args[0] != _signal.SIGTERM: Log.warning("exit with {{value}}", value=_describe_exit_codes.get(args[0], args[0])) except Exception as _: pass finally: MAIN...
python
def stop_main_thread(*args): """ CLEAN OF ALL THREADS CREATED WITH THIS LIBRARY """ try: if len(args) and args[0] != _signal.SIGTERM: Log.warning("exit with {{value}}", value=_describe_exit_codes.get(args[0], args[0])) except Exception as _: pass finally: MAIN...
[ "def", "stop_main_thread", "(", "*", "args", ")", ":", "try", ":", "if", "len", "(", "args", ")", "and", "args", "[", "0", "]", "!=", "_signal", ".", "SIGTERM", ":", "Log", ".", "warning", "(", "\"exit with {{value}}\"", ",", "value", "=", "_describe_e...
CLEAN OF ALL THREADS CREATED WITH THIS LIBRARY
[ "CLEAN", "OF", "ALL", "THREADS", "CREATED", "WITH", "THIS", "LIBRARY" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_threads/threads.py#L388-L398
klahnakoski/pyLibrary
mo_threads/threads.py
_wait_for_exit
def _wait_for_exit(please_stop): """ /dev/null PIPED TO sys.stdin SPEWS INFINITE LINES, DO NOT POLL AS OFTEN """ try: import msvcrt _wait_for_exit_on_windows(please_stop) except: pass cr_count = 0 # COUNT NUMBER OF BLANK LINES while not please_stop: # DEBUG...
python
def _wait_for_exit(please_stop): """ /dev/null PIPED TO sys.stdin SPEWS INFINITE LINES, DO NOT POLL AS OFTEN """ try: import msvcrt _wait_for_exit_on_windows(please_stop) except: pass cr_count = 0 # COUNT NUMBER OF BLANK LINES while not please_stop: # DEBUG...
[ "def", "_wait_for_exit", "(", "please_stop", ")", ":", "try", ":", "import", "msvcrt", "_wait_for_exit_on_windows", "(", "please_stop", ")", "except", ":", "pass", "cr_count", "=", "0", "# COUNT NUMBER OF BLANK LINES", "while", "not", "please_stop", ":", "# DEBUG an...
/dev/null PIPED TO sys.stdin SPEWS INFINITE LINES, DO NOT POLL AS OFTEN
[ "/", "dev", "/", "null", "PIPED", "TO", "sys", ".", "stdin", "SPEWS", "INFINITE", "LINES", "DO", "NOT", "POLL", "AS", "OFTEN" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_threads/threads.py#L410-L442
klahnakoski/pyLibrary
mo_threads/threads.py
AllThread.add
def add(self, target, *args, **kwargs): """ target IS THE FUNCTION TO EXECUTE IN THE THREAD """ t = Thread.run(target.__name__, target, *args, **kwargs) self.threads.append(t)
python
def add(self, target, *args, **kwargs): """ target IS THE FUNCTION TO EXECUTE IN THE THREAD """ t = Thread.run(target.__name__, target, *args, **kwargs) self.threads.append(t)
[ "def", "add", "(", "self", ",", "target", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "t", "=", "Thread", ".", "run", "(", "target", ".", "__name__", ",", "target", ",", "*", "args", ",", "*", "*", "kwargs", ")", "self", ".", "threads"...
target IS THE FUNCTION TO EXECUTE IN THE THREAD
[ "target", "IS", "THE", "FUNCTION", "TO", "EXECUTE", "IN", "THE", "THREAD" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_threads/threads.py#L68-L73
klahnakoski/pyLibrary
mo_threads/threads.py
MainThread.stop
def stop(self): """ BLOCKS UNTIL ALL THREADS HAVE STOPPED THEN RUNS sys.exit(0) """ global DEBUG self_thread = Thread.current() if self_thread != MAIN_THREAD or self_thread != self: Log.error("Only the main thread can call stop() on main thread") ...
python
def stop(self): """ BLOCKS UNTIL ALL THREADS HAVE STOPPED THEN RUNS sys.exit(0) """ global DEBUG self_thread = Thread.current() if self_thread != MAIN_THREAD or self_thread != self: Log.error("Only the main thread can call stop() on main thread") ...
[ "def", "stop", "(", "self", ")", ":", "global", "DEBUG", "self_thread", "=", "Thread", ".", "current", "(", ")", "if", "self_thread", "!=", "MAIN_THREAD", "or", "self_thread", "!=", "self", ":", "Log", ".", "error", "(", "\"Only the main thread can call stop()...
BLOCKS UNTIL ALL THREADS HAVE STOPPED THEN RUNS sys.exit(0)
[ "BLOCKS", "UNTIL", "ALL", "THREADS", "HAVE", "STOPPED", "THEN", "RUNS", "sys", ".", "exit", "(", "0", ")" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_threads/threads.py#L107-L149
klahnakoski/pyLibrary
mo_threads/threads.py
MainThread.wait_for_shutdown_signal
def wait_for_shutdown_signal( self, please_stop=False, # ASSIGN SIGNAL TO STOP EARLY allow_exit=False, # ALLOW "exit" COMMAND ON CONSOLE TO ALSO STOP THE APP wait_forever=True # IGNORE CHILD THREADS, NEVER EXIT. False => IF NO CHILD THREADS LEFT, THEN EXIT ): """ ...
python
def wait_for_shutdown_signal( self, please_stop=False, # ASSIGN SIGNAL TO STOP EARLY allow_exit=False, # ALLOW "exit" COMMAND ON CONSOLE TO ALSO STOP THE APP wait_forever=True # IGNORE CHILD THREADS, NEVER EXIT. False => IF NO CHILD THREADS LEFT, THEN EXIT ): """ ...
[ "def", "wait_for_shutdown_signal", "(", "self", ",", "please_stop", "=", "False", ",", "# ASSIGN SIGNAL TO STOP EARLY", "allow_exit", "=", "False", ",", "# ALLOW \"exit\" COMMAND ON CONSOLE TO ALSO STOP THE APP", "wait_forever", "=", "True", "# IGNORE CHILD THREADS, NEVER EXIT. ...
FOR USE BY PROCESSES THAT NEVER DIE UNLESS EXTERNAL SHUTDOWN IS REQUESTED CALLING THREAD WILL SLEEP UNTIL keyboard interrupt, OR please_stop, OR "exit" :param please_stop: :param allow_exit: :param wait_forever:: Assume all needed threads have been launched. When done :return:
[ "FOR", "USE", "BY", "PROCESSES", "THAT", "NEVER", "DIE", "UNLESS", "EXTERNAL", "SHUTDOWN", "IS", "REQUESTED" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_threads/threads.py#L151-L197
klahnakoski/pyLibrary
mo_threads/threads.py
Thread.stop
def stop(self): """ SEND STOP SIGNAL, DO NOT BLOCK """ with self.child_lock: children = copy(self.children) for c in children: DEBUG and c.name and Log.note("Stopping thread {{name|quote}}", name=c.name) c.stop() self.please_stop.go() ...
python
def stop(self): """ SEND STOP SIGNAL, DO NOT BLOCK """ with self.child_lock: children = copy(self.children) for c in children: DEBUG and c.name and Log.note("Stopping thread {{name|quote}}", name=c.name) c.stop() self.please_stop.go() ...
[ "def", "stop", "(", "self", ")", ":", "with", "self", ".", "child_lock", ":", "children", "=", "copy", "(", "self", ".", "children", ")", "for", "c", "in", "children", ":", "DEBUG", "and", "c", ".", "name", "and", "Log", ".", "note", "(", "\"Stoppi...
SEND STOP SIGNAL, DO NOT BLOCK
[ "SEND", "STOP", "SIGNAL", "DO", "NOT", "BLOCK" ]
train
https://github.com/klahnakoski/pyLibrary/blob/fa2dcbc48fda8d26999baef400e9a98149e0b982/mo_threads/threads.py#L250-L261