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
tonioo/sievelib
sievelib/managesieve.py
Client.havespace
def havespace(self, scriptname, scriptsize): """Ask for available space. See MANAGESIEVE specifications, section 2.5 :param scriptname: script's name :param scriptsize: script's size :rtype: boolean """ code, data = self.__send_command( "HAVESPACE", ...
python
def havespace(self, scriptname, scriptsize): """Ask for available space. See MANAGESIEVE specifications, section 2.5 :param scriptname: script's name :param scriptsize: script's size :rtype: boolean """ code, data = self.__send_command( "HAVESPACE", ...
[ "def", "havespace", "(", "self", ",", "scriptname", ",", "scriptsize", ")", ":", "code", ",", "data", "=", "self", ".", "__send_command", "(", "\"HAVESPACE\"", ",", "[", "scriptname", ".", "encode", "(", "\"utf-8\"", ")", ",", "scriptsize", "]", ")", "if...
Ask for available space. See MANAGESIEVE specifications, section 2.5 :param scriptname: script's name :param scriptsize: script's size :rtype: boolean
[ "Ask", "for", "available", "space", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L535-L548
tonioo/sievelib
sievelib/managesieve.py
Client.listscripts
def listscripts(self): """List available scripts. See MANAGESIEVE specifications, section 2.7 :returns: a 2-uple (active script, [script1, ...]) """ code, data, listing = self.__send_command( "LISTSCRIPTS", withcontent=True) if code == "NO": retu...
python
def listscripts(self): """List available scripts. See MANAGESIEVE specifications, section 2.7 :returns: a 2-uple (active script, [script1, ...]) """ code, data, listing = self.__send_command( "LISTSCRIPTS", withcontent=True) if code == "NO": retu...
[ "def", "listscripts", "(", "self", ")", ":", "code", ",", "data", ",", "listing", "=", "self", ".", "__send_command", "(", "\"LISTSCRIPTS\"", ",", "withcontent", "=", "True", ")", "if", "code", "==", "\"NO\"", ":", "return", "None", "ret", "=", "[", "]...
List available scripts. See MANAGESIEVE specifications, section 2.7 :returns: a 2-uple (active script, [script1, ...])
[ "List", "available", "scripts", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L551-L577
tonioo/sievelib
sievelib/managesieve.py
Client.getscript
def getscript(self, name): """Download a script from the server See MANAGESIEVE specifications, section 2.9 :param name: script's name :rtype: string :returns: the script's content on succes, None otherwise """ code, data, content = self.__send_command( ...
python
def getscript(self, name): """Download a script from the server See MANAGESIEVE specifications, section 2.9 :param name: script's name :rtype: string :returns: the script's content on succes, None otherwise """ code, data, content = self.__send_command( ...
[ "def", "getscript", "(", "self", ",", "name", ")", ":", "code", ",", "data", ",", "content", "=", "self", ".", "__send_command", "(", "\"GETSCRIPT\"", ",", "[", "name", ".", "encode", "(", "\"utf-8\"", ")", "]", ",", "withcontent", "=", "True", ")", ...
Download a script from the server See MANAGESIEVE specifications, section 2.9 :param name: script's name :rtype: string :returns: the script's content on succes, None otherwise
[ "Download", "a", "script", "from", "the", "server" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L580-L596
tonioo/sievelib
sievelib/managesieve.py
Client.putscript
def putscript(self, name, content): """Upload a script to the server See MANAGESIEVE specifications, section 2.6 :param name: script's name :param content: script's content :rtype: boolean """ content = tools.to_bytes(content) content = tools.to_bytes("{...
python
def putscript(self, name, content): """Upload a script to the server See MANAGESIEVE specifications, section 2.6 :param name: script's name :param content: script's content :rtype: boolean """ content = tools.to_bytes(content) content = tools.to_bytes("{...
[ "def", "putscript", "(", "self", ",", "name", ",", "content", ")", ":", "content", "=", "tools", ".", "to_bytes", "(", "content", ")", "content", "=", "tools", ".", "to_bytes", "(", "\"{%d+}\"", "%", "len", "(", "content", ")", ")", "+", "CRLF", "+",...
Upload a script to the server See MANAGESIEVE specifications, section 2.6 :param name: script's name :param content: script's content :rtype: boolean
[ "Upload", "a", "script", "to", "the", "server" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L599-L614
tonioo/sievelib
sievelib/managesieve.py
Client.deletescript
def deletescript(self, name): """Delete a script from the server See MANAGESIEVE specifications, section 2.10 :param name: script's name :rtype: boolean """ code, data = self.__send_command( "DELETESCRIPT", [name.encode("utf-8")]) if code == "OK": ...
python
def deletescript(self, name): """Delete a script from the server See MANAGESIEVE specifications, section 2.10 :param name: script's name :rtype: boolean """ code, data = self.__send_command( "DELETESCRIPT", [name.encode("utf-8")]) if code == "OK": ...
[ "def", "deletescript", "(", "self", ",", "name", ")", ":", "code", ",", "data", "=", "self", ".", "__send_command", "(", "\"DELETESCRIPT\"", ",", "[", "name", ".", "encode", "(", "\"utf-8\"", ")", "]", ")", "if", "code", "==", "\"OK\"", ":", "return", ...
Delete a script from the server See MANAGESIEVE specifications, section 2.10 :param name: script's name :rtype: boolean
[ "Delete", "a", "script", "from", "the", "server" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L617-L629
tonioo/sievelib
sievelib/managesieve.py
Client.renamescript
def renamescript(self, oldname, newname): """Rename a script on the server See MANAGESIEVE specifications, section 2.11.1 As this command is optional, we emulate it if the server does not support it. :param oldname: current script's name :param newname: new script's na...
python
def renamescript(self, oldname, newname): """Rename a script on the server See MANAGESIEVE specifications, section 2.11.1 As this command is optional, we emulate it if the server does not support it. :param oldname: current script's name :param newname: new script's na...
[ "def", "renamescript", "(", "self", ",", "oldname", ",", "newname", ")", ":", "if", "\"VERSION\"", "in", "self", ".", "__capabilities", ":", "code", ",", "data", "=", "self", ".", "__send_command", "(", "\"RENAMESCRIPT\"", ",", "[", "oldname", ".", "encode...
Rename a script on the server See MANAGESIEVE specifications, section 2.11.1 As this command is optional, we emulate it if the server does not support it. :param oldname: current script's name :param newname: new script's name :rtype: boolean
[ "Rename", "a", "script", "on", "the", "server" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L632-L673
tonioo/sievelib
sievelib/managesieve.py
Client.setactive
def setactive(self, scriptname): """Define the active script See MANAGESIEVE specifications, section 2.8 If scriptname is empty, the current active script is disabled, ie. there will be no active script anymore. :param scriptname: script's name :rtype: boolean ...
python
def setactive(self, scriptname): """Define the active script See MANAGESIEVE specifications, section 2.8 If scriptname is empty, the current active script is disabled, ie. there will be no active script anymore. :param scriptname: script's name :rtype: boolean ...
[ "def", "setactive", "(", "self", ",", "scriptname", ")", ":", "code", ",", "data", "=", "self", ".", "__send_command", "(", "\"SETACTIVE\"", ",", "[", "scriptname", ".", "encode", "(", "\"utf-8\"", ")", "]", ")", "if", "code", "==", "\"OK\"", ":", "ret...
Define the active script See MANAGESIEVE specifications, section 2.8 If scriptname is empty, the current active script is disabled, ie. there will be no active script anymore. :param scriptname: script's name :rtype: boolean
[ "Define", "the", "active", "script" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L676-L691
tonioo/sievelib
sievelib/managesieve.py
Client.checkscript
def checkscript(self, content): """Check whether a script is valid See MANAGESIEVE specifications, section 2.12 :param name: script's content :rtype: boolean """ if "VERSION" not in self.__capabilities: raise NotImplementedError( "server does...
python
def checkscript(self, content): """Check whether a script is valid See MANAGESIEVE specifications, section 2.12 :param name: script's content :rtype: boolean """ if "VERSION" not in self.__capabilities: raise NotImplementedError( "server does...
[ "def", "checkscript", "(", "self", ",", "content", ")", ":", "if", "\"VERSION\"", "not", "in", "self", ".", "__capabilities", ":", "raise", "NotImplementedError", "(", "\"server does not support CHECKSCRIPT command\"", ")", "content", "=", "tools", ".", "to_bytes", ...
Check whether a script is valid See MANAGESIEVE specifications, section 2.12 :param name: script's content :rtype: boolean
[ "Check", "whether", "a", "script", "is", "valid" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/managesieve.py#L694-L710
tonioo/sievelib
sievelib/parser.py
Lexer.scan
def scan(self, text): """Analyse some data Analyse the passed content. Each time a token is recognized, a 2-uple containing its name and parsed value is raised (via yield). On error, a ParseError exception is raised. :param text: a binary string containing the data to ...
python
def scan(self, text): """Analyse some data Analyse the passed content. Each time a token is recognized, a 2-uple containing its name and parsed value is raised (via yield). On error, a ParseError exception is raised. :param text: a binary string containing the data to ...
[ "def", "scan", "(", "self", ",", "text", ")", ":", "self", ".", "pos", "=", "0", "self", ".", "text", "=", "text", "while", "self", ".", "pos", "<", "len", "(", "text", ")", ":", "m", "=", "self", ".", "wsregexp", ".", "match", "(", "text", "...
Analyse some data Analyse the passed content. Each time a token is recognized, a 2-uple containing its name and parsed value is raised (via yield). On error, a ParseError exception is raised. :param text: a binary string containing the data to parse
[ "Analyse", "some", "data" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/parser.py#L63-L87
tonioo/sievelib
sievelib/parser.py
Parser.__reset_parser
def __reset_parser(self): """Reset parser's internal variables Restore the parser to an initial state. Useful when creating a new parser or reusing an existing one. """ self.result = [] self.hash_comments = [] self.__cstate = None self.__curcommand = Non...
python
def __reset_parser(self): """Reset parser's internal variables Restore the parser to an initial state. Useful when creating a new parser or reusing an existing one. """ self.result = [] self.hash_comments = [] self.__cstate = None self.__curcommand = Non...
[ "def", "__reset_parser", "(", "self", ")", ":", "self", ".", "result", "=", "[", "]", "self", ".", "hash_comments", "=", "[", "]", "self", ".", "__cstate", "=", "None", "self", ".", "__curcommand", "=", "None", "self", ".", "__curstringlist", "=", "Non...
Reset parser's internal variables Restore the parser to an initial state. Useful when creating a new parser or reusing an existing one.
[ "Reset", "parser", "s", "internal", "variables" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/parser.py#L124-L138
tonioo/sievelib
sievelib/parser.py
Parser.__up
def __up(self, onlyrecord=False): """Return to the current command's parent This method should be called each time a command is complete. In case of a top level command (no parent), it is recorded into a specific list for further usage. :param onlyrecord: tell to only record th...
python
def __up(self, onlyrecord=False): """Return to the current command's parent This method should be called each time a command is complete. In case of a top level command (no parent), it is recorded into a specific list for further usage. :param onlyrecord: tell to only record th...
[ "def", "__up", "(", "self", ",", "onlyrecord", "=", "False", ")", ":", "if", "self", ".", "__curcommand", ".", "must_follow", "is", "not", "None", ":", "if", "not", "self", ".", "__curcommand", ".", "parent", ":", "prevcmd", "=", "self", ".", "result",...
Return to the current command's parent This method should be called each time a command is complete. In case of a top level command (no parent), it is recorded into a specific list for further usage. :param onlyrecord: tell to only record the new command into its parent.
[ "Return", "to", "the", "current", "command", "s", "parent" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/parser.py#L148-L186
tonioo/sievelib
sievelib/parser.py
Parser.__check_command_completion
def __check_command_completion(self, testsemicolon=True): """Check for command(s) completion This function should be called each time a new argument is seen by the parser in order to check a command is complete. As not only one command can be ended when receiving a new argument ...
python
def __check_command_completion(self, testsemicolon=True): """Check for command(s) completion This function should be called each time a new argument is seen by the parser in order to check a command is complete. As not only one command can be ended when receiving a new argument ...
[ "def", "__check_command_completion", "(", "self", ",", "testsemicolon", "=", "True", ")", ":", "if", "not", "self", ".", "__curcommand", ".", "iscomplete", "(", ")", ":", "return", "True", "ctype", "=", "self", ".", "__curcommand", ".", "get_type", "(", ")...
Check for command(s) completion This function should be called each time a new argument is seen by the parser in order to check a command is complete. As not only one command can be ended when receiving a new argument (nested commands case), we apply the same work to parent comm...
[ "Check", "for", "command", "(", "s", ")", "completion" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/parser.py#L188-L228
tonioo/sievelib
sievelib/parser.py
Parser.__stringlist
def __stringlist(self, ttype, tvalue): """Specific method to parse the 'string-list' type Syntax: string-list = "[" string *("," string) "]" / string ; if there is only a single string, the brackets ; are optional """ i...
python
def __stringlist(self, ttype, tvalue): """Specific method to parse the 'string-list' type Syntax: string-list = "[" string *("," string) "]" / string ; if there is only a single string, the brackets ; are optional """ i...
[ "def", "__stringlist", "(", "self", ",", "ttype", ",", "tvalue", ")", ":", "if", "ttype", "==", "\"string\"", ":", "self", ".", "__curstringlist", "+=", "[", "tvalue", ".", "decode", "(", "\"utf-8\"", ")", "]", "self", ".", "__set_expected", "(", "\"comm...
Specific method to parse the 'string-list' type Syntax: string-list = "[" string *("," string) "]" / string ; if there is only a single string, the brackets ; are optional
[ "Specific", "method", "to", "parse", "the", "string", "-", "list", "type" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/parser.py#L230-L249
tonioo/sievelib
sievelib/parser.py
Parser.__argument
def __argument(self, ttype, tvalue): """Argument parsing method This method acts as an entry point for 'argument' parsing. Syntax: string-list / number / tag :param ttype: current token type :param tvalue: current token value :return: False if an error is e...
python
def __argument(self, ttype, tvalue): """Argument parsing method This method acts as an entry point for 'argument' parsing. Syntax: string-list / number / tag :param ttype: current token type :param tvalue: current token value :return: False if an error is e...
[ "def", "__argument", "(", "self", ",", "ttype", ",", "tvalue", ")", ":", "if", "ttype", "in", "[", "\"multiline\"", ",", "\"string\"", "]", ":", "return", "self", ".", "__curcommand", ".", "check_next_arg", "(", "\"string\"", ",", "tvalue", ".", "decode", ...
Argument parsing method This method acts as an entry point for 'argument' parsing. Syntax: string-list / number / tag :param ttype: current token type :param tvalue: current token value :return: False if an error is encountered, True otherwise
[ "Argument", "parsing", "method" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/parser.py#L251-L285
tonioo/sievelib
sievelib/parser.py
Parser.__arguments
def __arguments(self, ttype, tvalue): """Arguments parsing method Entry point for command arguments parsing. The parser must call this method for each parsed command (either a control, action or test). Syntax: *argument [ test / test-list ] :param ttype: cu...
python
def __arguments(self, ttype, tvalue): """Arguments parsing method Entry point for command arguments parsing. The parser must call this method for each parsed command (either a control, action or test). Syntax: *argument [ test / test-list ] :param ttype: cu...
[ "def", "__arguments", "(", "self", ",", "ttype", ",", "tvalue", ")", ":", "if", "ttype", "==", "\"identifier\"", ":", "test", "=", "get_command_instance", "(", "tvalue", ".", "decode", "(", "\"ascii\"", ")", ",", "self", ".", "__curcommand", ")", "self", ...
Arguments parsing method Entry point for command arguments parsing. The parser must call this method for each parsed command (either a control, action or test). Syntax: *argument [ test / test-list ] :param ttype: current token type :param tvalue: current t...
[ "Arguments", "parsing", "method" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/parser.py#L287-L323
tonioo/sievelib
sievelib/parser.py
Parser.__command
def __command(self, ttype, tvalue): """Command parsing method Entry point for command parsing. Here is expected behaviour: * Handle command beginning if detected, * Call the appropriate sub-method (specified by __cstate) to handle the body, * Handle command ending ...
python
def __command(self, ttype, tvalue): """Command parsing method Entry point for command parsing. Here is expected behaviour: * Handle command beginning if detected, * Call the appropriate sub-method (specified by __cstate) to handle the body, * Handle command ending ...
[ "def", "__command", "(", "self", ",", "ttype", ",", "tvalue", ")", ":", "if", "self", ".", "__cstate", "is", "None", ":", "if", "ttype", "==", "\"right_cbracket\"", ":", "self", ".", "__up", "(", ")", "self", ".", "__opened_blocks", "-=", "1", "self", ...
Command parsing method Entry point for command parsing. Here is expected behaviour: * Handle command beginning if detected, * Call the appropriate sub-method (specified by __cstate) to handle the body, * Handle command ending or block opening if detected. Syntax: ...
[ "Command", "parsing", "method" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/parser.py#L325-L382
tonioo/sievelib
sievelib/parser.py
Parser.parse
def parse(self, text): """The parser entry point. Parse the provided text to check for its validity. On success, the parsing tree is available into the result attribute. It is a list of sievecommands.Command objects (see the module documentation for specific information). ...
python
def parse(self, text): """The parser entry point. Parse the provided text to check for its validity. On success, the parsing tree is available into the result attribute. It is a list of sievecommands.Command objects (see the module documentation for specific information). ...
[ "def", "parse", "(", "self", ",", "text", ")", ":", "if", "isinstance", "(", "text", ",", "text_type", ")", ":", "text", "=", "text", ".", "encode", "(", "\"utf-8\"", ")", "self", ".", "__reset_parser", "(", ")", "try", ":", "for", "ttype", ",", "t...
The parser entry point. Parse the provided text to check for its validity. On success, the parsing tree is available into the result attribute. It is a list of sievecommands.Command objects (see the module documentation for specific information). On error, an string containing...
[ "The", "parser", "entry", "point", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/parser.py#L384-L441
tonioo/sievelib
sievelib/parser.py
Parser.parse_file
def parse_file(self, name): """Parse the content of a file. See 'parse' method for information. :param name: the pathname of the file to parse :return: True on success (no error detected), False otherwise """ with open(name, "rb") as fp: return self.parse(fp...
python
def parse_file(self, name): """Parse the content of a file. See 'parse' method for information. :param name: the pathname of the file to parse :return: True on success (no error detected), False otherwise """ with open(name, "rb") as fp: return self.parse(fp...
[ "def", "parse_file", "(", "self", ",", "name", ")", ":", "with", "open", "(", "name", ",", "\"rb\"", ")", "as", "fp", ":", "return", "self", ".", "parse", "(", "fp", ".", "read", "(", ")", ")" ]
Parse the content of a file. See 'parse' method for information. :param name: the pathname of the file to parse :return: True on success (no error detected), False otherwise
[ "Parse", "the", "content", "of", "a", "file", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/parser.py#L443-L452
tonioo/sievelib
sievelib/parser.py
Parser.dump
def dump(self, target=sys.stdout): """Dump the parsing tree. This method displays the parsing tree on the standard output. """ for r in self.result: r.dump(target=target)
python
def dump(self, target=sys.stdout): """Dump the parsing tree. This method displays the parsing tree on the standard output. """ for r in self.result: r.dump(target=target)
[ "def", "dump", "(", "self", ",", "target", "=", "sys", ".", "stdout", ")", ":", "for", "r", "in", "self", ".", "result", ":", "r", ".", "dump", "(", "target", "=", "target", ")" ]
Dump the parsing tree. This method displays the parsing tree on the standard output.
[ "Dump", "the", "parsing", "tree", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/parser.py#L454-L460
tonioo/sievelib
sievelib/commands.py
add_commands
def add_commands(cmds): """ Adds one or more commands to the module namespace. Commands must end in "Command" to be added. Example (see tests/parser.py): sievelib.commands.add_commands(MytestCommand) :param cmds: a single Command Object or list of Command Objects """ if not isinstance(c...
python
def add_commands(cmds): """ Adds one or more commands to the module namespace. Commands must end in "Command" to be added. Example (see tests/parser.py): sievelib.commands.add_commands(MytestCommand) :param cmds: a single Command Object or list of Command Objects """ if not isinstance(c...
[ "def", "add_commands", "(", "cmds", ")", ":", "if", "not", "isinstance", "(", "cmds", ",", "Iterable", ")", ":", "cmds", "=", "[", "cmds", "]", "for", "command", "in", "cmds", ":", "if", "command", ".", "__name__", ".", "endswith", "(", "\"Command\"", ...
Adds one or more commands to the module namespace. Commands must end in "Command" to be added. Example (see tests/parser.py): sievelib.commands.add_commands(MytestCommand) :param cmds: a single Command Object or list of Command Objects
[ "Adds", "one", "or", "more", "commands", "to", "the", "module", "namespace", ".", "Commands", "must", "end", "in", "Command", "to", "be", "added", ".", "Example", "(", "see", "tests", "/", "parser", ".", "py", ")", ":", "sievelib", ".", "commands", "."...
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/commands.py#L1069-L1083
tonioo/sievelib
sievelib/commands.py
get_command_instance
def get_command_instance(name, parent=None, checkexists=True): """Try to guess and create the appropriate command instance Given a command name (encountered by the parser), construct the associated class name and, if known, return a new instance. If the command is not known or has not been loaded usin...
python
def get_command_instance(name, parent=None, checkexists=True): """Try to guess and create the appropriate command instance Given a command name (encountered by the parser), construct the associated class name and, if known, return a new instance. If the command is not known or has not been loaded usin...
[ "def", "get_command_instance", "(", "name", ",", "parent", "=", "None", ",", "checkexists", "=", "True", ")", ":", "cname", "=", "\"%sCommand\"", "%", "name", ".", "lower", "(", ")", ".", "capitalize", "(", ")", "gl", "=", "globals", "(", ")", "conditi...
Try to guess and create the appropriate command instance Given a command name (encountered by the parser), construct the associated class name and, if known, return a new instance. If the command is not known or has not been loaded using require, an UnknownCommand exception is raised. :param name...
[ "Try", "to", "guess", "and", "create", "the", "appropriate", "command", "instance" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/commands.py#L1086-L1108
tonioo/sievelib
sievelib/commands.py
Command.tosieve
def tosieve(self, indentlevel=0, target=sys.stdout): """Generate the sieve syntax corresponding to this command Recursive method. :param indentlevel: current indentation level :param target: opened file pointer where the content will be printed """ self.__print(self.nam...
python
def tosieve(self, indentlevel=0, target=sys.stdout): """Generate the sieve syntax corresponding to this command Recursive method. :param indentlevel: current indentation level :param target: opened file pointer where the content will be printed """ self.__print(self.nam...
[ "def", "tosieve", "(", "self", ",", "indentlevel", "=", "0", ",", "target", "=", "sys", ".", "stdout", ")", ":", "self", ".", "__print", "(", "self", ".", "name", ",", "indentlevel", ",", "nocr", "=", "True", ",", "target", "=", "target", ")", "if"...
Generate the sieve syntax corresponding to this command Recursive method. :param indentlevel: current indentation level :param target: opened file pointer where the content will be printed
[ "Generate", "the", "sieve", "syntax", "corresponding", "to", "this", "command" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/commands.py#L157-L217
tonioo/sievelib
sievelib/commands.py
Command.dump
def dump(self, indentlevel=0, target=sys.stdout): """Display the command Pretty printing of this command and its eventual arguments and children. (recursively) :param indentlevel: integer that indicates indentation level to apply """ self.__print(self, indentlevel, targ...
python
def dump(self, indentlevel=0, target=sys.stdout): """Display the command Pretty printing of this command and its eventual arguments and children. (recursively) :param indentlevel: integer that indicates indentation level to apply """ self.__print(self, indentlevel, targ...
[ "def", "dump", "(", "self", ",", "indentlevel", "=", "0", ",", "target", "=", "sys", ".", "stdout", ")", ":", "self", ".", "__print", "(", "self", ",", "indentlevel", ",", "target", "=", "target", ")", "indentlevel", "+=", "4", "if", "self", ".", "...
Display the command Pretty printing of this command and its eventual arguments and children. (recursively) :param indentlevel: integer that indicates indentation level to apply
[ "Display", "the", "command" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/commands.py#L258-L294
tonioo/sievelib
sievelib/commands.py
Command.walk
def walk(self): """Walk through commands.""" yield self if self.has_arguments(): for arg in self.args_definition: if not arg["name"] in self.arguments: continue value = self.arguments[arg["name"]] if type(value) == l...
python
def walk(self): """Walk through commands.""" yield self if self.has_arguments(): for arg in self.args_definition: if not arg["name"] in self.arguments: continue value = self.arguments[arg["name"]] if type(value) == l...
[ "def", "walk", "(", "self", ")", ":", "yield", "self", "if", "self", ".", "has_arguments", "(", ")", ":", "for", "arg", "in", "self", ".", "args_definition", ":", "if", "not", "arg", "[", "\"name\"", "]", "in", "self", ".", "arguments", ":", "continu...
Walk through commands.
[ "Walk", "through", "commands", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/commands.py#L296-L314
tonioo/sievelib
sievelib/commands.py
Command.addchild
def addchild(self, child): """Add a new child to the command A child corresponds to a command located into a block (this command's block). It can be either an action or a control. :param child: the new child :return: True on succes, False otherwise """ if not se...
python
def addchild(self, child): """Add a new child to the command A child corresponds to a command located into a block (this command's block). It can be either an action or a control. :param child: the new child :return: True on succes, False otherwise """ if not se...
[ "def", "addchild", "(", "self", ",", "child", ")", ":", "if", "not", "self", ".", "accept_children", ":", "return", "False", "self", ".", "children", "+=", "[", "child", "]", "return", "True" ]
Add a new child to the command A child corresponds to a command located into a block (this command's block). It can be either an action or a control. :param child: the new child :return: True on succes, False otherwise
[ "Add", "a", "new", "child", "to", "the", "command" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/commands.py#L316-L328
tonioo/sievelib
sievelib/commands.py
Command.iscomplete
def iscomplete(self, atype=None, avalue=None): """Check if the command is complete Check if all required arguments have been encountered. For commands that allow an undefined number of arguments, this method always returns False. :return: True if command is complete, False othe...
python
def iscomplete(self, atype=None, avalue=None): """Check if the command is complete Check if all required arguments have been encountered. For commands that allow an undefined number of arguments, this method always returns False. :return: True if command is complete, False othe...
[ "def", "iscomplete", "(", "self", ",", "atype", "=", "None", ",", "avalue", "=", "None", ")", ":", "if", "self", ".", "variable_args_nb", ":", "return", "False", "if", "self", ".", "required_args", "==", "-", "1", ":", "self", ".", "required_args", "="...
Check if the command is complete Check if all required arguments have been encountered. For commands that allow an undefined number of arguments, this method always returns False. :return: True if command is complete, False otherwise
[ "Check", "if", "the", "command", "is", "complete" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/commands.py#L330-L353
tonioo/sievelib
sievelib/commands.py
Command.__is_valid_value_for_arg
def __is_valid_value_for_arg(self, arg, value, check_extension=True): """Check if value is allowed for arg Some commands only allow a limited set of values. The method always returns True for methods that do not provide such a set. :param arg: the argument's name :param...
python
def __is_valid_value_for_arg(self, arg, value, check_extension=True): """Check if value is allowed for arg Some commands only allow a limited set of values. The method always returns True for methods that do not provide such a set. :param arg: the argument's name :param...
[ "def", "__is_valid_value_for_arg", "(", "self", ",", "arg", ",", "value", ",", "check_extension", "=", "True", ")", ":", "if", "\"values\"", "not", "in", "arg", "and", "\"extension_values\"", "not", "in", "arg", ":", "return", "True", "if", "\"values\"", "in...
Check if value is allowed for arg Some commands only allow a limited set of values. The method always returns True for methods that do not provide such a set. :param arg: the argument's name :param value: the value to check :param check_extension: check if value require...
[ "Check", "if", "value", "is", "allowed", "for", "arg" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/commands.py#L361-L387
tonioo/sievelib
sievelib/commands.py
Command.__is_valid_type
def __is_valid_type(self, typ, typlist): """ Check if type is valid based on input type list "string" is special because it can be used for stringlist :param typ: the type to check :param typlist: the list of type to check :return: True on success, False otherwise ""...
python
def __is_valid_type(self, typ, typlist): """ Check if type is valid based on input type list "string" is special because it can be used for stringlist :param typ: the type to check :param typlist: the list of type to check :return: True on success, False otherwise ""...
[ "def", "__is_valid_type", "(", "self", ",", "typ", ",", "typlist", ")", ":", "typ_is_str", "=", "typ", "==", "\"string\"", "str_list_in_typlist", "=", "\"stringlist\"", "in", "typlist", "return", "typ", "in", "typlist", "or", "(", "typ_is_str", "and", "str_lis...
Check if type is valid based on input type list "string" is special because it can be used for stringlist :param typ: the type to check :param typlist: the list of type to check :return: True on success, False otherwise
[ "Check", "if", "type", "is", "valid", "based", "on", "input", "type", "list", "string", "is", "special", "because", "it", "can", "be", "used", "for", "stringlist" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/commands.py#L389-L400
tonioo/sievelib
sievelib/commands.py
Command.check_next_arg
def check_next_arg(self, atype, avalue, add=True, check_extension=True): """Argument validity checking This method is usually used by the parser to check if detected argument is allowed for this command. We make a distinction between required and optional arguments. Optional (o...
python
def check_next_arg(self, atype, avalue, add=True, check_extension=True): """Argument validity checking This method is usually used by the parser to check if detected argument is allowed for this command. We make a distinction between required and optional arguments. Optional (o...
[ "def", "check_next_arg", "(", "self", ",", "atype", ",", "avalue", ",", "add", "=", "True", ",", "check_extension", "=", "True", ")", ":", "if", "not", "self", ".", "has_arguments", "(", ")", ":", "return", "False", "if", "self", ".", "iscomplete", "("...
Argument validity checking This method is usually used by the parser to check if detected argument is allowed for this command. We make a distinction between required and optional arguments. Optional (or tagged) arguments can be provided unordered but not the required ones. ...
[ "Argument", "validity", "checking" ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/commands.py#L402-L499
tonioo/sievelib
sievelib/commands.py
ExistsCommand.args_as_tuple
def args_as_tuple(self): """FIXME: en fonction de la manière dont la commande a été générée (factory ou parser), le type des arguments est différent : string quand ça vient de la factory ou type normal depuis le parser. Il faut uniformiser tout ça !! """ value = self.arg...
python
def args_as_tuple(self): """FIXME: en fonction de la manière dont la commande a été générée (factory ou parser), le type des arguments est différent : string quand ça vient de la factory ou type normal depuis le parser. Il faut uniformiser tout ça !! """ value = self.arg...
[ "def", "args_as_tuple", "(", "self", ")", ":", "value", "=", "self", ".", "arguments", "[", "\"header-names\"", "]", "if", "isinstance", "(", "value", ",", "list", ")", ":", "value", "=", "\"[{}]\"", ".", "format", "(", "\",\"", ".", "join", "(", "'\"{...
FIXME: en fonction de la manière dont la commande a été générée (factory ou parser), le type des arguments est différent : string quand ça vient de la factory ou type normal depuis le parser. Il faut uniformiser tout ça !!
[ "FIXME", ":", "en", "fonction", "de", "la", "manière", "dont", "la", "commande", "a", "été", "générée", "(", "factory", "ou", "parser", ")", "le", "type", "des", "arguments", "est", "différent", ":", "string", "quand", "ça", "vient", "de", "la", "factory...
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/commands.py#L801-L814
tonioo/sievelib
sievelib/commands.py
HeaderCommand.args_as_tuple
def args_as_tuple(self): """Return arguments as a list.""" if "," in self.arguments["header-names"]: result = tuple(tools.to_list(self.arguments["header-names"])) else: result = (self.arguments["header-names"].strip('"'),) result = result + (self.arguments["match-...
python
def args_as_tuple(self): """Return arguments as a list.""" if "," in self.arguments["header-names"]: result = tuple(tools.to_list(self.arguments["header-names"])) else: result = (self.arguments["header-names"].strip('"'),) result = result + (self.arguments["match-...
[ "def", "args_as_tuple", "(", "self", ")", ":", "if", "\",\"", "in", "self", ".", "arguments", "[", "\"header-names\"", "]", ":", "result", "=", "tuple", "(", "tools", ".", "to_list", "(", "self", ".", "arguments", "[", "\"header-names\"", "]", ")", ")", ...
Return arguments as a list.
[ "Return", "arguments", "as", "a", "list", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/commands.py#L837-L849
tonioo/sievelib
sievelib/commands.py
BodyCommand.args_as_tuple
def args_as_tuple(self): """Return arguments as a list.""" result = ("body", ) result = result + ( self.arguments["body-transform"], self.arguments["match-type"]) if self.arguments["key-list"].startswith("["): result = result + tuple( tools.to_list...
python
def args_as_tuple(self): """Return arguments as a list.""" result = ("body", ) result = result + ( self.arguments["body-transform"], self.arguments["match-type"]) if self.arguments["key-list"].startswith("["): result = result + tuple( tools.to_list...
[ "def", "args_as_tuple", "(", "self", ")", ":", "result", "=", "(", "\"body\"", ",", ")", "result", "=", "result", "+", "(", "self", ".", "arguments", "[", "\"body-transform\"", "]", ",", "self", ".", "arguments", "[", "\"match-type\"", "]", ")", "if", ...
Return arguments as a list.
[ "Return", "arguments", "as", "a", "list", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/commands.py#L872-L882
tonioo/sievelib
sievelib/commands.py
HasflagCommand.reassign_arguments
def reassign_arguments(self): """Deal with optional stringlist before a required one.""" condition = ( "variable-list" in self.arguments and "list-of-flags" not in self.arguments ) if condition: self.arguments["list-of-flags"] = ( self....
python
def reassign_arguments(self): """Deal with optional stringlist before a required one.""" condition = ( "variable-list" in self.arguments and "list-of-flags" not in self.arguments ) if condition: self.arguments["list-of-flags"] = ( self....
[ "def", "reassign_arguments", "(", "self", ")", ":", "condition", "=", "(", "\"variable-list\"", "in", "self", ".", "arguments", "and", "\"list-of-flags\"", "not", "in", "self", ".", "arguments", ")", "if", "condition", ":", "self", ".", "arguments", "[", "\"...
Deal with optional stringlist before a required one.
[ "Deal", "with", "optional", "stringlist", "before", "a", "required", "one", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/commands.py#L929-L938
tonioo/sievelib
sievelib/commands.py
CurrentdateCommand.args_as_tuple
def args_as_tuple(self): """Return arguments as a list.""" result = ("currentdate", ) result += ( ":zone", self.extra_arguments["zone"].strip('"'), self.arguments["match-type"], ) if self.arguments["match-type"] in [":count", ":value"]: ...
python
def args_as_tuple(self): """Return arguments as a list.""" result = ("currentdate", ) result += ( ":zone", self.extra_arguments["zone"].strip('"'), self.arguments["match-type"], ) if self.arguments["match-type"] in [":count", ":value"]: ...
[ "def", "args_as_tuple", "(", "self", ")", ":", "result", "=", "(", "\"currentdate\"", ",", ")", "result", "+=", "(", "\":zone\"", ",", "self", ".", "extra_arguments", "[", "\"zone\"", "]", ".", "strip", "(", "'\"'", ")", ",", "self", ".", "arguments", ...
Return arguments as a list.
[ "Return", "arguments", "as", "a", "list", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/commands.py#L991-L1011
tonioo/sievelib
sievelib/tools.py
to_bytes
def to_bytes(s, encoding="utf-8"): """Convert a string to bytes.""" if isinstance(s, six.binary_type): return s if six.PY3: return bytes(s, encoding) return s.encode(encoding)
python
def to_bytes(s, encoding="utf-8"): """Convert a string to bytes.""" if isinstance(s, six.binary_type): return s if six.PY3: return bytes(s, encoding) return s.encode(encoding)
[ "def", "to_bytes", "(", "s", ",", "encoding", "=", "\"utf-8\"", ")", ":", "if", "isinstance", "(", "s", ",", "six", ".", "binary_type", ")", ":", "return", "s", "if", "six", ".", "PY3", ":", "return", "bytes", "(", "s", ",", "encoding", ")", "retur...
Convert a string to bytes.
[ "Convert", "a", "string", "to", "bytes", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/tools.py#L6-L12
tonioo/sievelib
sievelib/tools.py
to_list
def to_list(stringlist, unquote=True): """Convert a string representing a list to real list.""" stringlist = stringlist[1:-1] return [ string.strip('"') if unquote else string for string in stringlist.split(",") ]
python
def to_list(stringlist, unquote=True): """Convert a string representing a list to real list.""" stringlist = stringlist[1:-1] return [ string.strip('"') if unquote else string for string in stringlist.split(",") ]
[ "def", "to_list", "(", "stringlist", ",", "unquote", "=", "True", ")", ":", "stringlist", "=", "stringlist", "[", "1", ":", "-", "1", "]", "return", "[", "string", ".", "strip", "(", "'\"'", ")", "if", "unquote", "else", "string", "for", "string", "i...
Convert a string representing a list to real list.
[ "Convert", "a", "string", "representing", "a", "list", "to", "real", "list", "." ]
train
https://github.com/tonioo/sievelib/blob/88822d1f1daf30ef3dd9ac74911301b0773ef3c8/sievelib/tools.py#L15-L21
mozilla/puente
puente/utils.py
monkeypatch_i18n
def monkeypatch_i18n(): """Alleviates problems with extraction for trans blocks Jinja2 has a ``babel_extract`` function which sets up a Jinja2 environment to parse Jinja2 templates to extract strings for translation. That's awesome! Yay! However, when it goes to set up the environment, it checks to...
python
def monkeypatch_i18n(): """Alleviates problems with extraction for trans blocks Jinja2 has a ``babel_extract`` function which sets up a Jinja2 environment to parse Jinja2 templates to extract strings for translation. That's awesome! Yay! However, when it goes to set up the environment, it checks to...
[ "def", "monkeypatch_i18n", "(", ")", ":", "import", "jinja2", ".", "ext", "from", "puente", ".", "ext", "import", "PuenteI18nExtension", "jinja2", ".", "ext", ".", "InternationalizationExtension", "=", "PuenteI18nExtension", "jinja2", ".", "ext", ".", "i18n", "=...
Alleviates problems with extraction for trans blocks Jinja2 has a ``babel_extract`` function which sets up a Jinja2 environment to parse Jinja2 templates to extract strings for translation. That's awesome! Yay! However, when it goes to set up the environment, it checks to see if the environment has...
[ "Alleviates", "problems", "with", "extraction", "for", "trans", "blocks" ]
train
https://github.com/mozilla/puente/blob/4379a7717d28a2490d47939800f5d6e695b70def/puente/utils.py#L4-L60
mozilla/puente
puente/utils.py
generate_keywords
def generate_keywords(additional_keywords=None): """Generates gettext keywords list :arg additional_keywords: dict of keyword -> value :returns: dict of keyword -> values for Babel extraction Here's what Babel has for DEFAULT_KEYWORDS:: DEFAULT_KEYWORDS = { '_': None, ...
python
def generate_keywords(additional_keywords=None): """Generates gettext keywords list :arg additional_keywords: dict of keyword -> value :returns: dict of keyword -> values for Babel extraction Here's what Babel has for DEFAULT_KEYWORDS:: DEFAULT_KEYWORDS = { '_': None, ...
[ "def", "generate_keywords", "(", "additional_keywords", "=", "None", ")", ":", "# Shallow copy", "keywords", "=", "dict", "(", "BABEL_KEYWORDS", ")", "keywords", ".", "update", "(", "{", "'_lazy'", ":", "None", ",", "'gettext_lazy'", ":", "None", ",", "'ugette...
Generates gettext keywords list :arg additional_keywords: dict of keyword -> value :returns: dict of keyword -> values for Babel extraction Here's what Babel has for DEFAULT_KEYWORDS:: DEFAULT_KEYWORDS = { '_': None, 'gettext': None, 'ngettext': (1, 2), ...
[ "Generates", "gettext", "keywords", "list" ]
train
https://github.com/mozilla/puente/blob/4379a7717d28a2490d47939800f5d6e695b70def/puente/utils.py#L63-L117
mozilla/puente
puente/utils.py
collapse_whitespace
def collapse_whitespace(message): """Collapses consecutive whitespace into a single space""" return u' '.join(map(lambda s: s.strip(), filter(None, message.strip().splitlines())))
python
def collapse_whitespace(message): """Collapses consecutive whitespace into a single space""" return u' '.join(map(lambda s: s.strip(), filter(None, message.strip().splitlines())))
[ "def", "collapse_whitespace", "(", "message", ")", ":", "return", "u' '", ".", "join", "(", "map", "(", "lambda", "s", ":", "s", ".", "strip", "(", ")", ",", "filter", "(", "None", ",", "message", ".", "strip", "(", ")", ".", "splitlines", "(", ")"...
Collapses consecutive whitespace into a single space
[ "Collapses", "consecutive", "whitespace", "into", "a", "single", "space" ]
train
https://github.com/mozilla/puente/blob/4379a7717d28a2490d47939800f5d6e695b70def/puente/utils.py#L120-L123
mozilla/puente
puente/commands.py
generate_options_map
def generate_options_map(): """Generate an ``options_map` to pass to ``extract_from_dir`` This is the options_map that's used to generate a Jinja2 environment. We want to generate and environment for extraction that's the same as the environment we use for rendering. This allows developers to expl...
python
def generate_options_map(): """Generate an ``options_map` to pass to ``extract_from_dir`` This is the options_map that's used to generate a Jinja2 environment. We want to generate and environment for extraction that's the same as the environment we use for rendering. This allows developers to expl...
[ "def", "generate_options_map", "(", ")", ":", "try", ":", "return", "settings", ".", "PUENTE", "[", "'JINJA2_CONFIG'", "]", "except", "KeyError", ":", "pass", "# If using Django 1.8+, we can skim the TEMPLATES for a backend that we", "# know about and extract the settings from ...
Generate an ``options_map` to pass to ``extract_from_dir`` This is the options_map that's used to generate a Jinja2 environment. We want to generate and environment for extraction that's the same as the environment we use for rendering. This allows developers to explicitly set a ``JINJA2_CONFIG`` in s...
[ "Generate", "an", "options_map", "to", "pass", "to", "extract_from_dir" ]
train
https://github.com/mozilla/puente/blob/4379a7717d28a2490d47939800f5d6e695b70def/puente/commands.py#L14-L64
mozilla/puente
puente/commands.py
extract_command
def extract_command(outputdir, domain_methods, text_domain, keywords, comment_tags, base_dir, project, version, msgid_bugs_address): """Extracts strings into .pot files :arg domain: domains to generate strings for or 'all' for all domains :arg outputdir: output dir f...
python
def extract_command(outputdir, domain_methods, text_domain, keywords, comment_tags, base_dir, project, version, msgid_bugs_address): """Extracts strings into .pot files :arg domain: domains to generate strings for or 'all' for all domains :arg outputdir: output dir f...
[ "def", "extract_command", "(", "outputdir", ",", "domain_methods", ",", "text_domain", ",", "keywords", ",", "comment_tags", ",", "base_dir", ",", "project", ",", "version", ",", "msgid_bugs_address", ")", ":", "# Must monkeypatch first to fix i18n extensions stomping iss...
Extracts strings into .pot files :arg domain: domains to generate strings for or 'all' for all domains :arg outputdir: output dir for .pot files; usually locale/templates/LC_MESSAGES/ :arg domain_methods: DOMAIN_METHODS setting :arg text_domain: TEXT_DOMAIN settings :arg keywords: KEYWORDS ...
[ "Extracts", "strings", "into", ".", "pot", "files" ]
train
https://github.com/mozilla/puente/blob/4379a7717d28a2490d47939800f5d6e695b70def/puente/commands.py#L67-L129
mozilla/puente
puente/commands.py
merge_command
def merge_command(create, backup, base_dir, domain_methods, languages): """ :arg create: whether or not to create directories if they don't exist :arg backup: whether or not to create backup .po files :arg base_dir: BASE_DIR setting :arg domain_methods: DOMAIN_METHODS setting :arg langua...
python
def merge_command(create, backup, base_dir, domain_methods, languages): """ :arg create: whether or not to create directories if they don't exist :arg backup: whether or not to create backup .po files :arg base_dir: BASE_DIR setting :arg domain_methods: DOMAIN_METHODS setting :arg langua...
[ "def", "merge_command", "(", "create", ",", "backup", ",", "base_dir", ",", "domain_methods", ",", "languages", ")", ":", "locale_dir", "=", "os", ".", "path", ".", "join", "(", "base_dir", ",", "'locale'", ")", "# Verify existence of msginit and msgmerge", "if"...
:arg create: whether or not to create directories if they don't exist :arg backup: whether or not to create backup .po files :arg base_dir: BASE_DIR setting :arg domain_methods: DOMAIN_METHODS setting :arg languages: LANGUAGES setting
[ ":", "arg", "create", ":", "whether", "or", "not", "to", "create", "directories", "if", "they", "don", "t", "exist", ":", "arg", "backup", ":", "whether", "or", "not", "to", "create", "backup", ".", "po", "files", ":", "arg", "base_dir", ":", "BASE_DIR...
train
https://github.com/mozilla/puente/blob/4379a7717d28a2490d47939800f5d6e695b70def/puente/commands.py#L132-L213
mozilla/puente
puente/commands.py
_msgmerge
def _msgmerge(po_path, pot_file, backup): """Merge an existing .po file with new translations. :arg po_path: path to the .po file :arg pot_file: a file-like object for the related templates :arg backup: whether or not to create backup .po files """ pot_file.seek(0) command = [ 'msgm...
python
def _msgmerge(po_path, pot_file, backup): """Merge an existing .po file with new translations. :arg po_path: path to the .po file :arg pot_file: a file-like object for the related templates :arg backup: whether or not to create backup .po files """ pot_file.seek(0) command = [ 'msgm...
[ "def", "_msgmerge", "(", "po_path", ",", "pot_file", ",", "backup", ")", ":", "pot_file", ".", "seek", "(", "0", ")", "command", "=", "[", "'msgmerge'", ",", "'--update'", ",", "'--width=200'", ",", "'--backup=%s'", "%", "(", "'simple'", "if", "backup", ...
Merge an existing .po file with new translations. :arg po_path: path to the .po file :arg pot_file: a file-like object for the related templates :arg backup: whether or not to create backup .po files
[ "Merge", "an", "existing", ".", "po", "file", "with", "new", "translations", "." ]
train
https://github.com/mozilla/puente/blob/4379a7717d28a2490d47939800f5d6e695b70def/puente/commands.py#L216-L233
elsampsa/valkka-live
valkka/mvision/multiprocess.py
QValkkaProcess.run
def run(self): # No "_" in the name, but nevertheless, running in the backed """After the fork. Now the process starts running """ self.preRun_() self.running=True while(self.running): self.cycle_() self.handleSignal_() self.postR...
python
def run(self): # No "_" in the name, but nevertheless, running in the backed """After the fork. Now the process starts running """ self.preRun_() self.running=True while(self.running): self.cycle_() self.handleSignal_() self.postR...
[ "def", "run", "(", "self", ")", ":", "# No \"_\" in the name, but nevertheless, running in the backed", "self", ".", "preRun_", "(", ")", "self", ".", "running", "=", "True", "while", "(", "self", ".", "running", ")", ":", "self", ".", "cycle_", "(", ")", "s...
After the fork. Now the process starts running
[ "After", "the", "fork", ".", "Now", "the", "process", "starts", "running" ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/multiprocess.py#L58-L68
elsampsa/valkka-live
valkka/mvision/multiprocess.py
QValkkaShmemProcess.preRun_
def preRun_(self): """Create the shared memory client immediately after fork """ self.report("preRun_") super().preRun_() self.client = ShmemRGBClient( name=self.shmem_name, n_ringbuffer=self.n_buffer, # size of ring buffer width=self.image_d...
python
def preRun_(self): """Create the shared memory client immediately after fork """ self.report("preRun_") super().preRun_() self.client = ShmemRGBClient( name=self.shmem_name, n_ringbuffer=self.n_buffer, # size of ring buffer width=self.image_d...
[ "def", "preRun_", "(", "self", ")", ":", "self", ".", "report", "(", "\"preRun_\"", ")", "super", "(", ")", ".", "preRun_", "(", ")", "self", ".", "client", "=", "ShmemRGBClient", "(", "name", "=", "self", ".", "shmem_name", ",", "n_ringbuffer", "=", ...
Create the shared memory client immediately after fork
[ "Create", "the", "shared", "memory", "client", "immediately", "after", "fork" ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/multiprocess.py#L150-L163
elsampsa/valkka-live
valkka/mvision/multiprocess.py
QValkkaShmemProcess2.run
def run(self): # No "_" in the name, but nevertheless, running in the backed """After the fork. Now the process starts running """ self.preRun_() self.running=True while(self.running): if (self.active): # activated: shared mem client has been reserved ...
python
def run(self): # No "_" in the name, but nevertheless, running in the backed """After the fork. Now the process starts running """ self.preRun_() self.running=True while(self.running): if (self.active): # activated: shared mem client has been reserved ...
[ "def", "run", "(", "self", ")", ":", "# No \"_\" in the name, but nevertheless, running in the backed", "self", ".", "preRun_", "(", ")", "self", ".", "running", "=", "True", "while", "(", "self", ".", "running", ")", ":", "if", "(", "self", ".", "active", "...
After the fork. Now the process starts running
[ "After", "the", "fork", ".", "Now", "the", "process", "starts", "running" ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/multiprocess.py#L273-L287
elsampsa/valkka-live
valkka/mvision/multiprocess.py
QValkkaShmemProcess2.activate_
def activate_(self, n_buffer, image_dimensions, shmem_name): """Shared mem info is given. Now we can create the shmem client """ self.active = True self.image_dimensions = image_dimensions self.client = ShmemRGBClient( name =shmem_name, n_ringb...
python
def activate_(self, n_buffer, image_dimensions, shmem_name): """Shared mem info is given. Now we can create the shmem client """ self.active = True self.image_dimensions = image_dimensions self.client = ShmemRGBClient( name =shmem_name, n_ringb...
[ "def", "activate_", "(", "self", ",", "n_buffer", ",", "image_dimensions", ",", "shmem_name", ")", ":", "self", ".", "active", "=", "True", "self", ".", "image_dimensions", "=", "image_dimensions", "self", ".", "client", "=", "ShmemRGBClient", "(", "name", "...
Shared mem info is given. Now we can create the shmem client
[ "Shared", "mem", "info", "is", "given", ".", "Now", "we", "can", "create", "the", "shmem", "client" ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/multiprocess.py#L313-L327
elsampsa/valkka-live
valkka/mvision/multiprocess.py
QValkkaShmemProcess2.deactivate_
def deactivate_(self): """Init shmem variables to None """ self.preDeactivate_() self.active = False self.image_dimensions = None self.client = None
python
def deactivate_(self): """Init shmem variables to None """ self.preDeactivate_() self.active = False self.image_dimensions = None self.client = None
[ "def", "deactivate_", "(", "self", ")", ":", "self", ".", "preDeactivate_", "(", ")", "self", ".", "active", "=", "False", "self", ".", "image_dimensions", "=", "None", "self", ".", "client", "=", "None" ]
Init shmem variables to None
[ "Init", "shmem", "variables", "to", "None" ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/multiprocess.py#L334-L340
elsampsa/valkka-live
valkka/mvision/nix/base.py
ExternalDetector.init
def init(self): """Start the process """ import subprocess import fcntl width = str(self.image_dimensions[0]) height = str(self.image_dimensions[1]) comlist = self.executable.split() + [width, height, self.tmpfile] # e.g. "python3", "example_proc...
python
def init(self): """Start the process """ import subprocess import fcntl width = str(self.image_dimensions[0]) height = str(self.image_dimensions[1]) comlist = self.executable.split() + [width, height, self.tmpfile] # e.g. "python3", "example_proc...
[ "def", "init", "(", "self", ")", ":", "import", "subprocess", "import", "fcntl", "width", "=", "str", "(", "self", ".", "image_dimensions", "[", "0", "]", ")", "height", "=", "str", "(", "self", ".", "image_dimensions", "[", "1", "]", ")", "comlist", ...
Start the process
[ "Start", "the", "process" ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/nix/base.py#L58-L75
elsampsa/valkka-live
valkka/mvision/nix/base.py
ExternalDetector.reset
def reset(self): """Tell the external analyzer to reset itself """ self.report("sending reset") try: self.p.stdin.write(bytes("T\n","utf-8")) self.p.stdin.flush() except IOError: self.report("could not send reset command")
python
def reset(self): """Tell the external analyzer to reset itself """ self.report("sending reset") try: self.p.stdin.write(bytes("T\n","utf-8")) self.p.stdin.flush() except IOError: self.report("could not send reset command")
[ "def", "reset", "(", "self", ")", ":", "self", ".", "report", "(", "\"sending reset\"", ")", "try", ":", "self", ".", "p", ".", "stdin", ".", "write", "(", "bytes", "(", "\"T\\n\"", ",", "\"utf-8\"", ")", ")", "self", ".", "p", ".", "stdin", ".", ...
Tell the external analyzer to reset itself
[ "Tell", "the", "external", "analyzer", "to", "reset", "itself" ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/nix/base.py#L78-L86
elsampsa/valkka-live
valkka/mvision/nix/base.py
ExternalDetector.close
def close(self): """Tell the process to exit """ try: self.p.stdin.write(bytes("X\n","utf-8")) self.p.stdin.flush() except IOError: self.report("could not send exit command") self.p.wait() # wait until the process is closed try: ...
python
def close(self): """Tell the process to exit """ try: self.p.stdin.write(bytes("X\n","utf-8")) self.p.stdin.flush() except IOError: self.report("could not send exit command") self.p.wait() # wait until the process is closed try: ...
[ "def", "close", "(", "self", ")", ":", "try", ":", "self", ".", "p", ".", "stdin", ".", "write", "(", "bytes", "(", "\"X\\n\"", ",", "\"utf-8\"", ")", ")", "self", ".", "p", ".", "stdin", ".", "flush", "(", ")", "except", "IOError", ":", "self", ...
Tell the process to exit
[ "Tell", "the", "process", "to", "exit" ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/nix/base.py#L89-L101
elsampsa/valkka-live
valkka/mvision/nix/base.py
ExternalDetector.readStdout
def readStdout(self): """Not used """ btt = bytes() while True: bt = self.p.stdout.read(1) if bt: btt += bt else: # print("!") break """ if (bt == "\n"): break ...
python
def readStdout(self): """Not used """ btt = bytes() while True: bt = self.p.stdout.read(1) if bt: btt += bt else: # print("!") break """ if (bt == "\n"): break ...
[ "def", "readStdout", "(", "self", ")", ":", "btt", "=", "bytes", "(", ")", "while", "True", ":", "bt", "=", "self", ".", "p", ".", "stdout", ".", "read", "(", "1", ")", "if", "bt", ":", "btt", "+=", "bt", "else", ":", "# print(\"!\")", "break", ...
Not used
[ "Not", "used" ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/nix/base.py#L131-L146
elsampsa/valkka-live
valkka/mvision/nix/base.py
MVisionProcess.postActivate_
def postActivate_(self): """Create temporary file for image dumps and the analyzer itself """ self.tmpfile = os.path.join(constant.tmpdir,"valkka-"+str(os.getpid())) # e.g. "/tmp/valkka-10968" self.analyzer = ExternalDetector( executable = self.executable, image_...
python
def postActivate_(self): """Create temporary file for image dumps and the analyzer itself """ self.tmpfile = os.path.join(constant.tmpdir,"valkka-"+str(os.getpid())) # e.g. "/tmp/valkka-10968" self.analyzer = ExternalDetector( executable = self.executable, image_...
[ "def", "postActivate_", "(", "self", ")", ":", "self", ".", "tmpfile", "=", "os", ".", "path", ".", "join", "(", "constant", ".", "tmpdir", ",", "\"valkka-\"", "+", "str", "(", "os", ".", "getpid", "(", ")", ")", ")", "# e.g. \"/tmp/valkka-10968\" ", "...
Create temporary file for image dumps and the analyzer itself
[ "Create", "temporary", "file", "for", "image", "dumps", "and", "the", "analyzer", "itself" ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/nix/base.py#L198-L206
veripress/veripress
veripress_cli/generate.py
generate_pages_by_file
def generate_pages_by_file(): """Generates custom pages of 'file' storage type.""" from veripress import app from veripress.model import storage from veripress.model.parsers import get_standard_format_name from veripress.helpers import traverse_directory deploy_dir = get_deploy_dir() def c...
python
def generate_pages_by_file(): """Generates custom pages of 'file' storage type.""" from veripress import app from veripress.model import storage from veripress.model.parsers import get_standard_format_name from veripress.helpers import traverse_directory deploy_dir = get_deploy_dir() def c...
[ "def", "generate_pages_by_file", "(", ")", ":", "from", "veripress", "import", "app", "from", "veripress", ".", "model", "import", "storage", "from", "veripress", ".", "model", ".", "parsers", "import", "get_standard_format_name", "from", "veripress", ".", "helper...
Generates custom pages of 'file' storage type.
[ "Generates", "custom", "pages", "of", "file", "storage", "type", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress_cli/generate.py#L123-L159
elsampsa/valkka-live
valkka/live/datamodel.py
DataModel.autoGenerateCameraCollection
def autoGenerateCameraCollection(self, base_address, nstart, n, port, tail, username, password): """ :param: base_address str, e.g. "192.168.1" :param: nstart int, e.g. 24 :param: n int, how many ips generated """ self.camera_collection.clear...
python
def autoGenerateCameraCollection(self, base_address, nstart, n, port, tail, username, password): """ :param: base_address str, e.g. "192.168.1" :param: nstart int, e.g. 24 :param: n int, how many ips generated """ self.camera_collection.clear...
[ "def", "autoGenerateCameraCollection", "(", "self", ",", "base_address", ",", "nstart", ",", "n", ",", "port", ",", "tail", ",", "username", ",", "password", ")", ":", "self", ".", "camera_collection", ".", "clear", "(", ")", "self", ".", "camera_collection"...
:param: base_address str, e.g. "192.168.1" :param: nstart int, e.g. 24 :param: n int, how many ips generated
[ ":", "param", ":", "base_address", "str", "e", ".", "g", ".", "192", ".", "168", ".", "1", ":", "param", ":", "nstart", "int", "e", ".", "g", ".", "24", ":", "param", ":", "n", "int", "how", "many", "ips", "generated" ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/live/datamodel.py#L667-L709
elsampsa/valkka-live
valkka/live/datamodel.py
DataModel.define
def define(self): """Define column patterns and collections """ self.collections = [] self.camera_collection = \ SimpleCollection(filename=os.path.join(self.directory, "devices.dat"), row_classes=[ DataModel.EmptyRow, ...
python
def define(self): """Define column patterns and collections """ self.collections = [] self.camera_collection = \ SimpleCollection(filename=os.path.join(self.directory, "devices.dat"), row_classes=[ DataModel.EmptyRow, ...
[ "def", "define", "(", "self", ")", ":", "self", ".", "collections", "=", "[", "]", "self", ".", "camera_collection", "=", "SimpleCollection", "(", "filename", "=", "os", ".", "path", ".", "join", "(", "self", ".", "directory", ",", "\"devices.dat\"", ")"...
Define column patterns and collections
[ "Define", "column", "patterns", "and", "collections" ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/live/datamodel.py#L720-L741
elsampsa/valkka-live
valkka/live/datamodel.py
DataModel.getDevicesById
def getDevicesById(self): # , query): """ rows = self.camera_collection.get(query) devices_by_id = {} for row in rows: row.pop("classname") device = DataModel.RTSPCameraDevice(**row) devices_by_id[device._id] = device return devices_by_id ...
python
def getDevicesById(self): # , query): """ rows = self.camera_collection.get(query) devices_by_id = {} for row in rows: row.pop("classname") device = DataModel.RTSPCameraDevice(**row) devices_by_id[device._id] = device return devices_by_id ...
[ "def", "getDevicesById", "(", "self", ")", ":", "# , query):", "rows", "=", "self", ".", "camera_collection", ".", "get", "(", ")", "devices_by_id", "=", "{", "}", "for", "row", "in", "rows", ":", "classname", "=", "row", ".", "pop", "(", "\"classname\""...
rows = self.camera_collection.get(query) devices_by_id = {} for row in rows: row.pop("classname") device = DataModel.RTSPCameraDevice(**row) devices_by_id[device._id] = device return devices_by_id
[ "rows", "=", "self", ".", "camera_collection", ".", "get", "(", "query", ")", "devices_by_id", "=", "{}", "for", "row", "in", "rows", ":", "row", ".", "pop", "(", "classname", ")", "device", "=", "DataModel", ".", "RTSPCameraDevice", "(", "**", "row", ...
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/live/datamodel.py#L766-L788
elsampsa/valkka-live
valkka/mvision/alpr/base.py
LicensePlateDetector.init
def init(self): """Init alpr The LicensePlateDetector object gets instantiated in the multiprocess, so the library is imported in the multiprocess (i.e. "other side of the fork") as well """ # some modules might need to be imported "on the other side of the fork" # .. bu...
python
def init(self): """Init alpr The LicensePlateDetector object gets instantiated in the multiprocess, so the library is imported in the multiprocess (i.e. "other side of the fork") as well """ # some modules might need to be imported "on the other side of the fork" # .. bu...
[ "def", "init", "(", "self", ")", ":", "# some modules might need to be imported \"on the other side of the fork\"", "# .. but the, when importing this module, the import is not tested", "#", "# ", "# from openalpr import Alpr", "from", "valkka", ".", "mvision", ".", "alpr", ".", ...
Init alpr The LicensePlateDetector object gets instantiated in the multiprocess, so the library is imported in the multiprocess (i.e. "other side of the fork") as well
[ "Init", "alpr", "The", "LicensePlateDetector", "object", "gets", "instantiated", "in", "the", "multiprocess", "so", "the", "library", "is", "imported", "in", "the", "multiprocess", "(", "i", ".", "e", ".", "other", "side", "of", "the", "fork", ")", "as", "...
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/alpr/base.py#L75-L102
elsampsa/valkka-live
valkka/mvision/alpr/base.py
MVisionProcess.postActivate_
def postActivate_(self): """Whatever you need to do after creating the shmem client """ self.analyzer = LicensePlateDetector(**self.analyzer_pars) # this is called after the fork (i.e. after the multiprocess has been spawned) self.report("analyzer object=", self.analyzer)
python
def postActivate_(self): """Whatever you need to do after creating the shmem client """ self.analyzer = LicensePlateDetector(**self.analyzer_pars) # this is called after the fork (i.e. after the multiprocess has been spawned) self.report("analyzer object=", self.analyzer)
[ "def", "postActivate_", "(", "self", ")", ":", "self", ".", "analyzer", "=", "LicensePlateDetector", "(", "*", "*", "self", ".", "analyzer_pars", ")", "# this is called after the fork (i.e. after the multiprocess has been spawned)", "self", ".", "report", "(", "\"analyz...
Whatever you need to do after creating the shmem client
[ "Whatever", "you", "need", "to", "do", "after", "creating", "the", "shmem", "client" ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/alpr/base.py#L203-L207
Jaymon/pout
pout/path.py
SiteCustomizeFile.inject
def inject(self): """inject code into sitecustomize.py that will inject pout into the builtins so it will be available globally""" if self.is_injected(): return False with open(self, mode="a+") as fp: fp.seek(0) fp.write("\n".join([ ""...
python
def inject(self): """inject code into sitecustomize.py that will inject pout into the builtins so it will be available globally""" if self.is_injected(): return False with open(self, mode="a+") as fp: fp.seek(0) fp.write("\n".join([ ""...
[ "def", "inject", "(", "self", ")", ":", "if", "self", ".", "is_injected", "(", ")", ":", "return", "False", "with", "open", "(", "self", ",", "mode", "=", "\"a+\"", ")", "as", "fp", ":", "fp", ".", "seek", "(", "0", ")", "fp", ".", "write", "("...
inject code into sitecustomize.py that will inject pout into the builtins so it will be available globally
[ "inject", "code", "into", "sitecustomize", ".", "py", "that", "will", "inject", "pout", "into", "the", "builtins", "so", "it", "will", "be", "available", "globally" ]
train
https://github.com/Jaymon/pout/blob/fa71b64384ddeb3b538855ed93e785d9985aad05/pout/path.py#L103-L122
veripress/veripress
veripress/model/storages.py
Storage.fix_relative_url
def fix_relative_url(self, publish_type, rel_url): """ Fix post or page relative url to a standard, uniform format. :param publish_type: publish type ('post' or 'page') :param rel_url: relative url to fix :return: tuple(fixed relative url or file path if exists else None, ...
python
def fix_relative_url(self, publish_type, rel_url): """ Fix post or page relative url to a standard, uniform format. :param publish_type: publish type ('post' or 'page') :param rel_url: relative url to fix :return: tuple(fixed relative url or file path if exists else None, ...
[ "def", "fix_relative_url", "(", "self", ",", "publish_type", ",", "rel_url", ")", ":", "if", "publish_type", "==", "'post'", ":", "return", "self", ".", "fix_post_relative_url", "(", "rel_url", ")", ",", "False", "elif", "publish_type", "==", "'page'", ":", ...
Fix post or page relative url to a standard, uniform format. :param publish_type: publish type ('post' or 'page') :param rel_url: relative url to fix :return: tuple(fixed relative url or file path if exists else None, file exists or not) :raise ValueError: unknown...
[ "Fix", "post", "or", "page", "relative", "url", "to", "a", "standard", "uniform", "format", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/model/storages.py#L38-L54
veripress/veripress
veripress/model/storages.py
Storage.fix_post_relative_url
def fix_post_relative_url(rel_url): """ Fix post relative url to a standard, uniform format. Possible input: - 2016/7/8/my-post - 2016/07/08/my-post.html - 2016/8/09/my-post/ - 2016/8/09/my-post/index - 2016/8/09/my-post/index.htm - 2016/8/09/my-p...
python
def fix_post_relative_url(rel_url): """ Fix post relative url to a standard, uniform format. Possible input: - 2016/7/8/my-post - 2016/07/08/my-post.html - 2016/8/09/my-post/ - 2016/8/09/my-post/index - 2016/8/09/my-post/index.htm - 2016/8/09/my-p...
[ "def", "fix_post_relative_url", "(", "rel_url", ")", ":", "m", "=", "re", ".", "match", "(", "r'^(?P<year>\\d{4})/(?P<month>\\d{1,2})/(?P<day>\\d{1,2})/'", "r'(?P<post_name>[^/]+?)'", "r'(?:(?:\\.html)|(?:/(?P<index>index(?:\\.html?)?)?))?$'", ",", "rel_url", ")", "if", "not", ...
Fix post relative url to a standard, uniform format. Possible input: - 2016/7/8/my-post - 2016/07/08/my-post.html - 2016/8/09/my-post/ - 2016/8/09/my-post/index - 2016/8/09/my-post/index.htm - 2016/8/09/my-post/index.html :param rel_url: relative url to ...
[ "Fix", "post", "relative", "url", "to", "a", "standard", "uniform", "format", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/model/storages.py#L58-L89
veripress/veripress
veripress/model/storages.py
Storage._filter_result
def _filter_result(result, filter_functions=None): """ Filter result with given filter functions. :param result: an iterable object :param filter_functions: some filter functions :return: a filter object (filtered result) """ if filter_functions is not None: ...
python
def _filter_result(result, filter_functions=None): """ Filter result with given filter functions. :param result: an iterable object :param filter_functions: some filter functions :return: a filter object (filtered result) """ if filter_functions is not None: ...
[ "def", "_filter_result", "(", "result", ",", "filter_functions", "=", "None", ")", ":", "if", "filter_functions", "is", "not", "None", ":", "for", "filter_func", "in", "filter_functions", ":", "result", "=", "filter", "(", "filter_func", ",", "result", ")", ...
Filter result with given filter functions. :param result: an iterable object :param filter_functions: some filter functions :return: a filter object (filtered result)
[ "Filter", "result", "with", "given", "filter", "functions", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/model/storages.py#L160-L171
veripress/veripress
veripress/model/storages.py
Storage.get_posts_with_limits
def get_posts_with_limits(self, include_draft=False, **limits): """ Get all posts and filter them as needed. :param include_draft: return draft posts or not :param limits: other limits to the attrs of the result, should be a dict with string or list values ...
python
def get_posts_with_limits(self, include_draft=False, **limits): """ Get all posts and filter them as needed. :param include_draft: return draft posts or not :param limits: other limits to the attrs of the result, should be a dict with string or list values ...
[ "def", "get_posts_with_limits", "(", "self", ",", "include_draft", "=", "False", ",", "*", "*", "limits", ")", ":", "filter_funcs", "=", "[", "]", "for", "attr", "in", "(", "'title'", ",", "'layout'", ",", "'author'", ",", "'email'", ",", "'tags'", ",", ...
Get all posts and filter them as needed. :param include_draft: return draft posts or not :param limits: other limits to the attrs of the result, should be a dict with string or list values :return: an iterable of Post objects
[ "Get", "all", "posts", "and", "filter", "them", "as", "needed", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/model/storages.py#L173-L218
veripress/veripress
veripress/model/storages.py
Storage.search_for
def search_for(self, query, include_draft=False): """ Search for a query text. :param query: keyword to query :param include_draft: return draft posts/pages or not :return: an iterable object of posts and pages (if allowed). """ query = query.lower() if n...
python
def search_for(self, query, include_draft=False): """ Search for a query text. :param query: keyword to query :param include_draft: return draft posts/pages or not :return: an iterable object of posts and pages (if allowed). """ query = query.lower() if n...
[ "def", "search_for", "(", "self", ",", "query", ",", "include_draft", "=", "False", ")", ":", "query", "=", "query", ".", "lower", "(", ")", "if", "not", "query", ":", "return", "[", "]", "def", "contains_query_keyword", "(", "post_or_page", ")", ":", ...
Search for a query text. :param query: keyword to query :param include_draft: return draft posts/pages or not :return: an iterable object of posts and pages (if allowed).
[ "Search", "for", "a", "query", "text", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/model/storages.py#L220-L244
veripress/veripress
veripress/model/storages.py
FileStorage.fix_page_relative_url
def fix_page_relative_url(rel_url): """ Fix page relative url to a standard, uniform format. Possible input: - my-page - my-page/ - my-page/index - my-page/index.htm - my-page/index.html - my-page/specific.file :param rel_url: relative ur...
python
def fix_page_relative_url(rel_url): """ Fix page relative url to a standard, uniform format. Possible input: - my-page - my-page/ - my-page/index - my-page/index.htm - my-page/index.html - my-page/specific.file :param rel_url: relative ur...
[ "def", "fix_page_relative_url", "(", "rel_url", ")", ":", "rel_url", "=", "rel_url", ".", "lstrip", "(", "'/'", ")", "# trim all heading '/'", "endswith_slash", "=", "rel_url", ".", "endswith", "(", "'/'", ")", "rel_url", "=", "rel_url", ".", "rstrip", "(", ...
Fix page relative url to a standard, uniform format. Possible input: - my-page - my-page/ - my-page/index - my-page/index.htm - my-page/index.html - my-page/specific.file :param rel_url: relative url to fix :return: tuple(fixed relative url or FI...
[ "Fix", "page", "relative", "url", "to", "a", "standard", "uniform", "format", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/model/storages.py#L250-L299
veripress/veripress
veripress/model/storages.py
FileStorage.search_file
def search_file(search_root, search_filename, instance_relative_root=False): """ Search for a filename in a specific search root dir. :param search_root: root dir to search :param search_filename: filename to search (no extension) :param instance_relative_roo...
python
def search_file(search_root, search_filename, instance_relative_root=False): """ Search for a filename in a specific search root dir. :param search_root: root dir to search :param search_filename: filename to search (no extension) :param instance_relative_roo...
[ "def", "search_file", "(", "search_root", ",", "search_filename", ",", "instance_relative_root", "=", "False", ")", ":", "if", "instance_relative_root", ":", "search_root", "=", "os", ".", "path", ".", "join", "(", "current_app", ".", "instance_path", ",", "sear...
Search for a filename in a specific search root dir. :param search_root: root dir to search :param search_filename: filename to search (no extension) :param instance_relative_root: search root is relative to instance path :return: tuple(full_file_path, extension without heading dot)
[ "Search", "for", "a", "filename", "in", "a", "specific", "search", "root", "dir", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/model/storages.py#L303-L323
veripress/veripress
veripress/model/storages.py
FileStorage.read_file
def read_file(file_path): """ Read yaml head and raw body content from a file. :param file_path: file path :return: tuple(meta, raw_content) """ with open(file_path, 'r', encoding='utf-8') as f: whole = f.read().strip() if whole.startswith('---'): ...
python
def read_file(file_path): """ Read yaml head and raw body content from a file. :param file_path: file path :return: tuple(meta, raw_content) """ with open(file_path, 'r', encoding='utf-8') as f: whole = f.read().strip() if whole.startswith('---'): ...
[ "def", "read_file", "(", "file_path", ")", ":", "with", "open", "(", "file_path", ",", "'r'", ",", "encoding", "=", "'utf-8'", ")", "as", "f", ":", "whole", "=", "f", ".", "read", "(", ")", ".", "strip", "(", ")", "if", "whole", ".", "startswith", ...
Read yaml head and raw body content from a file. :param file_path: file path :return: tuple(meta, raw_content)
[ "Read", "yaml", "head", "and", "raw", "body", "content", "from", "a", "file", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/model/storages.py#L331-L347
veripress/veripress
veripress/model/storages.py
FileStorage.get_posts
def get_posts(self, include_draft=False, filter_functions=None): """ Get all posts from filesystem. :param include_draft: return draft posts or not :param filter_functions: filter to apply BEFORE result being sorted :return: an iterable of Post objects (the first is the latest p...
python
def get_posts(self, include_draft=False, filter_functions=None): """ Get all posts from filesystem. :param include_draft: return draft posts or not :param filter_functions: filter to apply BEFORE result being sorted :return: an iterable of Post objects (the first is the latest p...
[ "def", "get_posts", "(", "self", ",", "include_draft", "=", "False", ",", "filter_functions", "=", "None", ")", ":", "def", "posts_generator", "(", "path", ")", ":", "\"\"\"Loads valid posts one by one in the given path.\"\"\"", "if", "os", ".", "path", ".", "isdi...
Get all posts from filesystem. :param include_draft: return draft posts or not :param filter_functions: filter to apply BEFORE result being sorted :return: an iterable of Post objects (the first is the latest post)
[ "Get", "all", "posts", "from", "filesystem", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/model/storages.py#L350-L382
veripress/veripress
veripress/model/storages.py
FileStorage.get_post
def get_post(self, rel_url, include_draft=False): """ Get post for given relative url from filesystem. Possible input: - 2017/01/01/my-post/ - 2017/01/01/my-post/index.html :param rel_url: relative url :param include_draft: return draft post or not :retu...
python
def get_post(self, rel_url, include_draft=False): """ Get post for given relative url from filesystem. Possible input: - 2017/01/01/my-post/ - 2017/01/01/my-post/index.html :param rel_url: relative url :param include_draft: return draft post or not :retu...
[ "def", "get_post", "(", "self", ",", "rel_url", ",", "include_draft", "=", "False", ")", ":", "raw_rel_url", "=", "str", "(", "rel_url", ")", "if", "rel_url", ".", "endswith", "(", "'/index.html'", ")", ":", "rel_url", "=", "rel_url", ".", "rsplit", "(",...
Get post for given relative url from filesystem. Possible input: - 2017/01/01/my-post/ - 2017/01/01/my-post/index.html :param rel_url: relative url :param include_draft: return draft post or not :return: a Post object
[ "Get", "post", "for", "given", "relative", "url", "from", "filesystem", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/model/storages.py#L385-L417
veripress/veripress
veripress/model/storages.py
FileStorage.get_tags
def get_tags(self): """ Get all tags and post count of each tag. :return: dict_item(tag_name, Pair(count_all, count_published)) """ posts = self.get_posts(include_draft=True) result = {} for post in posts: for tag_name in set(post.tags): ...
python
def get_tags(self): """ Get all tags and post count of each tag. :return: dict_item(tag_name, Pair(count_all, count_published)) """ posts = self.get_posts(include_draft=True) result = {} for post in posts: for tag_name in set(post.tags): ...
[ "def", "get_tags", "(", "self", ")", ":", "posts", "=", "self", ".", "get_posts", "(", "include_draft", "=", "True", ")", "result", "=", "{", "}", "for", "post", "in", "posts", ":", "for", "tag_name", "in", "set", "(", "post", ".", "tags", ")", ":"...
Get all tags and post count of each tag. :return: dict_item(tag_name, Pair(count_all, count_published))
[ "Get", "all", "tags", "and", "post", "count", "of", "each", "tag", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/model/storages.py#L420-L432
veripress/veripress
veripress/model/storages.py
FileStorage.get_categories
def get_categories(self): """ Get all categories and post count of each category. :return dict_item(category_name, Pair(count_all, count_published)) """ posts = self.get_posts(include_draft=True) result = {} for post in posts: for category_name in set...
python
def get_categories(self): """ Get all categories and post count of each category. :return dict_item(category_name, Pair(count_all, count_published)) """ posts = self.get_posts(include_draft=True) result = {} for post in posts: for category_name in set...
[ "def", "get_categories", "(", "self", ")", ":", "posts", "=", "self", ".", "get_posts", "(", "include_draft", "=", "True", ")", "result", "=", "{", "}", "for", "post", "in", "posts", ":", "for", "category_name", "in", "set", "(", "post", ".", "categori...
Get all categories and post count of each category. :return dict_item(category_name, Pair(count_all, count_published))
[ "Get", "all", "categories", "and", "post", "count", "of", "each", "category", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/model/storages.py#L435-L448
veripress/veripress
veripress/model/storages.py
FileStorage.get_pages
def get_pages(self, include_draft=False): """ Get all custom pages (supported formats, excluding other files like '.js', '.css', '.html'). :param include_draft: return draft page or not :return: an iterable of Page objects """ def pages_generator(pages_root_path...
python
def get_pages(self, include_draft=False): """ Get all custom pages (supported formats, excluding other files like '.js', '.css', '.html'). :param include_draft: return draft page or not :return: an iterable of Page objects """ def pages_generator(pages_root_path...
[ "def", "get_pages", "(", "self", ",", "include_draft", "=", "False", ")", ":", "def", "pages_generator", "(", "pages_root_path", ")", ":", "for", "file_path", "in", "traverse_directory", "(", "pages_root_path", ",", "yield_dir", "=", "False", ")", ":", "rel_pa...
Get all custom pages (supported formats, excluding other files like '.js', '.css', '.html'). :param include_draft: return draft page or not :return: an iterable of Page objects
[ "Get", "all", "custom", "pages", "(", "supported", "formats", "excluding", "other", "files", "like", ".", "js", ".", "css", ".", "html", ")", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/model/storages.py#L451-L479
veripress/veripress
veripress/model/storages.py
FileStorage.get_page
def get_page(self, rel_url, include_draft=False): """ Get custom page for given relative url from filesystem. Possible input: - my-page/ - my-page/index.html - my-another-page.html - a/b/c/ - a/b/c/d.html :param rel_url: relative url :par...
python
def get_page(self, rel_url, include_draft=False): """ Get custom page for given relative url from filesystem. Possible input: - my-page/ - my-page/index.html - my-another-page.html - a/b/c/ - a/b/c/d.html :param rel_url: relative url :par...
[ "def", "get_page", "(", "self", ",", "rel_url", ",", "include_draft", "=", "False", ")", ":", "page_dir", "=", "os", ".", "path", ".", "dirname", "(", "rel_url", ".", "replace", "(", "'/'", ",", "os", ".", "path", ".", "sep", ")", ")", "page_path", ...
Get custom page for given relative url from filesystem. Possible input: - my-page/ - my-page/index.html - my-another-page.html - a/b/c/ - a/b/c/d.html :param rel_url: relative url :param include_draft: return draft page or not :return: a Page obj...
[ "Get", "custom", "page", "for", "given", "relative", "url", "from", "filesystem", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/model/storages.py#L482-L523
veripress/veripress
veripress/model/storages.py
FileStorage.get_widgets
def get_widgets(self, position=None, include_draft=False): """ Get widgets for given position from filesystem. :param position: position or position list :param include_draft: return draft widgets or not :return: an iterable of Widget objects """ def widgets_gen...
python
def get_widgets(self, position=None, include_draft=False): """ Get widgets for given position from filesystem. :param position: position or position list :param include_draft: return draft widgets or not :return: an iterable of Widget objects """ def widgets_gen...
[ "def", "get_widgets", "(", "self", ",", "position", "=", "None", ",", "include_draft", "=", "False", ")", ":", "def", "widgets_generator", "(", "path", ")", ":", "\"\"\"Loads valid widgets one by one in the given path.\"\"\"", "if", "os", ".", "path", ".", "isdir"...
Get widgets for given position from filesystem. :param position: position or position list :param include_draft: return draft widgets or not :return: an iterable of Widget objects
[ "Get", "widgets", "for", "given", "position", "from", "filesystem", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/model/storages.py#L526-L556
veripress/veripress
veripress/view/__init__.py
custom_render_template
def custom_render_template(template_name_or_list, **context): """ Try to render templates in the custom folder first, if no custom templates, try the theme's default ones. """ response_str = render_template( functools.reduce(lambda x, y: x + [os.path.join('custom', y), y], ...
python
def custom_render_template(template_name_or_list, **context): """ Try to render templates in the custom folder first, if no custom templates, try the theme's default ones. """ response_str = render_template( functools.reduce(lambda x, y: x + [os.path.join('custom', y), y], ...
[ "def", "custom_render_template", "(", "template_name_or_list", ",", "*", "*", "context", ")", ":", "response_str", "=", "render_template", "(", "functools", ".", "reduce", "(", "lambda", "x", ",", "y", ":", "x", "+", "[", "os", ".", "path", ".", "join", ...
Try to render templates in the custom folder first, if no custom templates, try the theme's default ones.
[ "Try", "to", "render", "templates", "in", "the", "custom", "folder", "first", "if", "no", "custom", "templates", "try", "the", "theme", "s", "default", "ones", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/view/__init__.py#L36-L50
veripress/veripress
veripress/view/__init__.py
templated
def templated(template=None, *templates): """ Decorate a view function with one or more default template name. This will try templates in the custom folder first, the theme's original ones second. :param template: template name or template name list """ def decorator(func): @functo...
python
def templated(template=None, *templates): """ Decorate a view function with one or more default template name. This will try templates in the custom folder first, the theme's original ones second. :param template: template name or template name list """ def decorator(func): @functo...
[ "def", "templated", "(", "template", "=", "None", ",", "*", "templates", ")", ":", "def", "decorator", "(", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", ...
Decorate a view function with one or more default template name. This will try templates in the custom folder first, the theme's original ones second. :param template: template name or template name list
[ "Decorate", "a", "view", "function", "with", "one", "or", "more", "default", "template", "name", ".", "This", "will", "try", "templates", "in", "the", "custom", "folder", "first", "the", "theme", "s", "original", "ones", "second", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/view/__init__.py#L53-L79
veripress/veripress
veripress_cli/helpers.py
copy_folder_content
def copy_folder_content(src, dst): """ Copy all content in src directory to dst directory. The src and dst must exist. """ for file in os.listdir(src): file_path = os.path.join(src, file) dst_file_path = os.path.join(dst, file) if os.path.isdir(file_path): shutil....
python
def copy_folder_content(src, dst): """ Copy all content in src directory to dst directory. The src and dst must exist. """ for file in os.listdir(src): file_path = os.path.join(src, file) dst_file_path = os.path.join(dst, file) if os.path.isdir(file_path): shutil....
[ "def", "copy_folder_content", "(", "src", ",", "dst", ")", ":", "for", "file", "in", "os", ".", "listdir", "(", "src", ")", ":", "file_path", "=", "os", ".", "path", ".", "join", "(", "src", ",", "file", ")", "dst_file_path", "=", "os", ".", "path"...
Copy all content in src directory to dst directory. The src and dst must exist.
[ "Copy", "all", "content", "in", "src", "directory", "to", "dst", "directory", ".", "The", "src", "and", "dst", "must", "exist", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress_cli/helpers.py#L5-L16
veripress/veripress
veripress_cli/helpers.py
remove_folder_content
def remove_folder_content(path, ignore_hidden_file=False): """ Remove all content in the given folder. """ for file in os.listdir(path): if ignore_hidden_file and file.startswith('.'): continue file_path = os.path.join(path, file) if os.path.isdir(file_path): ...
python
def remove_folder_content(path, ignore_hidden_file=False): """ Remove all content in the given folder. """ for file in os.listdir(path): if ignore_hidden_file and file.startswith('.'): continue file_path = os.path.join(path, file) if os.path.isdir(file_path): ...
[ "def", "remove_folder_content", "(", "path", ",", "ignore_hidden_file", "=", "False", ")", ":", "for", "file", "in", "os", ".", "listdir", "(", "path", ")", ":", "if", "ignore_hidden_file", "and", "file", ".", "startswith", "(", "'.'", ")", ":", "continue"...
Remove all content in the given folder.
[ "Remove", "all", "content", "in", "the", "given", "folder", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress_cli/helpers.py#L19-L31
veripress/veripress
veripress_cli/helpers.py
makedirs
def makedirs(path, mode=0o777, exist_ok=False): """A wrapper of os.makedirs().""" os.makedirs(path, mode, exist_ok)
python
def makedirs(path, mode=0o777, exist_ok=False): """A wrapper of os.makedirs().""" os.makedirs(path, mode, exist_ok)
[ "def", "makedirs", "(", "path", ",", "mode", "=", "0o777", ",", "exist_ok", "=", "False", ")", ":", "os", ".", "makedirs", "(", "path", ",", "mode", ",", "exist_ok", ")" ]
A wrapper of os.makedirs().
[ "A", "wrapper", "of", "os", ".", "makedirs", "()", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress_cli/helpers.py#L34-L36
elsampsa/valkka-live
valkka/mvision/alpr/openalpr_fix.py
Alpr.unload
def unload(self): """ Unloads OpenALPR from memory. :return: None """ if self.loaded: self.loaded = False self._openalprpy_lib.dispose(self.alpr_pointer)
python
def unload(self): """ Unloads OpenALPR from memory. :return: None """ if self.loaded: self.loaded = False self._openalprpy_lib.dispose(self.alpr_pointer)
[ "def", "unload", "(", "self", ")", ":", "if", "self", ".", "loaded", ":", "self", ".", "loaded", "=", "False", "self", ".", "_openalprpy_lib", ".", "dispose", "(", "self", ".", "alpr_pointer", ")" ]
Unloads OpenALPR from memory. :return: None
[ "Unloads", "OpenALPR", "from", "memory", "." ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/alpr/openalpr_fix.py#L127-L136
elsampsa/valkka-live
valkka/mvision/alpr/openalpr_fix.py
Alpr.recognize_file
def recognize_file(self, file_path): """ This causes OpenALPR to attempt to recognize an image by opening a file on disk. :param file_path: The path to the image that will be analyzed :return: An OpenALPR analysis in the form of a response dictionary """ file_pat...
python
def recognize_file(self, file_path): """ This causes OpenALPR to attempt to recognize an image by opening a file on disk. :param file_path: The path to the image that will be analyzed :return: An OpenALPR analysis in the form of a response dictionary """ file_pat...
[ "def", "recognize_file", "(", "self", ",", "file_path", ")", ":", "file_path", "=", "_convert_to_charp", "(", "file_path", ")", "ptr", "=", "self", ".", "_recognize_file_func", "(", "self", ".", "alpr_pointer", ",", "file_path", ")", "json_data", "=", "ctypes"...
This causes OpenALPR to attempt to recognize an image by opening a file on disk. :param file_path: The path to the image that will be analyzed :return: An OpenALPR analysis in the form of a response dictionary
[ "This", "causes", "OpenALPR", "to", "attempt", "to", "recognize", "an", "image", "by", "opening", "a", "file", "on", "disk", "." ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/alpr/openalpr_fix.py#L149-L163
elsampsa/valkka-live
valkka/mvision/alpr/openalpr_fix.py
Alpr.recognize_array
def recognize_array(self, byte_array): """ This causes OpenALPR to attempt to recognize an image passed in as a byte array. :param byte_array: This should be a string (Python 2) or a bytes object (Python 3) :return: An OpenALPR analysis in the form of a response dictionary """ ...
python
def recognize_array(self, byte_array): """ This causes OpenALPR to attempt to recognize an image passed in as a byte array. :param byte_array: This should be a string (Python 2) or a bytes object (Python 3) :return: An OpenALPR analysis in the form of a response dictionary """ ...
[ "def", "recognize_array", "(", "self", ",", "byte_array", ")", ":", "if", "type", "(", "byte_array", ")", "!=", "bytes", ":", "raise", "TypeError", "(", "\"Expected a byte array (string in Python 2, bytes in Python 3)\"", ")", "pb", "=", "ctypes", ".", "cast", "("...
This causes OpenALPR to attempt to recognize an image passed in as a byte array. :param byte_array: This should be a string (Python 2) or a bytes object (Python 3) :return: An OpenALPR analysis in the form of a response dictionary
[ "This", "causes", "OpenALPR", "to", "attempt", "to", "recognize", "an", "image", "passed", "in", "as", "a", "byte", "array", "." ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/alpr/openalpr_fix.py#L165-L180
elsampsa/valkka-live
valkka/mvision/alpr/openalpr_fix.py
Alpr.recognize_ndarray
def recognize_ndarray(self, ndarray): """ This causes OpenALPR to attempt to recognize an image passed in as a numpy array. :param ndarray: numpy.array as used in cv2 module :return: An OpenALPR analysis in the form of a response dictionary """ if self._recognize_raw_ima...
python
def recognize_ndarray(self, ndarray): """ This causes OpenALPR to attempt to recognize an image passed in as a numpy array. :param ndarray: numpy.array as used in cv2 module :return: An OpenALPR analysis in the form of a response dictionary """ if self._recognize_raw_ima...
[ "def", "recognize_ndarray", "(", "self", ",", "ndarray", ")", ":", "if", "self", ".", "_recognize_raw_image_func", "is", "None", ":", "raise", "RuntimeError", "(", "'NumPy missing'", ")", "height", ",", "width", "=", "ndarray", ".", "shape", "[", ":", "2", ...
This causes OpenALPR to attempt to recognize an image passed in as a numpy array. :param ndarray: numpy.array as used in cv2 module :return: An OpenALPR analysis in the form of a response dictionary
[ "This", "causes", "OpenALPR", "to", "attempt", "to", "recognize", "an", "image", "passed", "in", "as", "a", "numpy", "array", "." ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/alpr/openalpr_fix.py#L182-L205
elsampsa/valkka-live
valkka/mvision/alpr/openalpr_fix.py
Alpr.get_version
def get_version(self): """ This gets the version of OpenALPR :return: Version information """ ptr = self._get_version_func(self.alpr_pointer) version_number = ctypes.cast(ptr, ctypes.c_char_p).value version_number = _convert_from_charp(version_number) se...
python
def get_version(self): """ This gets the version of OpenALPR :return: Version information """ ptr = self._get_version_func(self.alpr_pointer) version_number = ctypes.cast(ptr, ctypes.c_char_p).value version_number = _convert_from_charp(version_number) se...
[ "def", "get_version", "(", "self", ")", ":", "ptr", "=", "self", ".", "_get_version_func", "(", "self", ".", "alpr_pointer", ")", "version_number", "=", "ctypes", ".", "cast", "(", "ptr", ",", "ctypes", ".", "c_char_p", ")", ".", "value", "version_number",...
This gets the version of OpenALPR :return: Version information
[ "This", "gets", "the", "version", "of", "OpenALPR" ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/alpr/openalpr_fix.py#L207-L218
elsampsa/valkka-live
valkka/mvision/alpr/openalpr_fix.py
Alpr.set_country
def set_country(self, country): """ This sets the country for detecting license plates. For example, setting country to "us" for United States or "eu" for Europe. :param country: A unicode/ascii string (Python 2/3) or bytes array (Python 3) :return: None """ coun...
python
def set_country(self, country): """ This sets the country for detecting license plates. For example, setting country to "us" for United States or "eu" for Europe. :param country: A unicode/ascii string (Python 2/3) or bytes array (Python 3) :return: None """ coun...
[ "def", "set_country", "(", "self", ",", "country", ")", ":", "country", "=", "_convert_to_charp", "(", "country", ")", "self", ".", "_set_country_func", "(", "self", ".", "alpr_pointer", ",", "country", ")" ]
This sets the country for detecting license plates. For example, setting country to "us" for United States or "eu" for Europe. :param country: A unicode/ascii string (Python 2/3) or bytes array (Python 3) :return: None
[ "This", "sets", "the", "country", "for", "detecting", "license", "plates", ".", "For", "example", "setting", "country", "to", "us", "for", "United", "States", "or", "eu", "for", "Europe", "." ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/alpr/openalpr_fix.py#L230-L239
elsampsa/valkka-live
valkka/mvision/alpr/openalpr_fix.py
Alpr.set_prewarp
def set_prewarp(self, prewarp): """ Updates the prewarp configuration used to skew images in OpenALPR before processing. :param prewarp: A unicode/ascii string (Python 2/3) or bytes array (Python 3) :return: None """ prewarp = _convert_to_charp(prewarp) s...
python
def set_prewarp(self, prewarp): """ Updates the prewarp configuration used to skew images in OpenALPR before processing. :param prewarp: A unicode/ascii string (Python 2/3) or bytes array (Python 3) :return: None """ prewarp = _convert_to_charp(prewarp) s...
[ "def", "set_prewarp", "(", "self", ",", "prewarp", ")", ":", "prewarp", "=", "_convert_to_charp", "(", "prewarp", ")", "self", ".", "_set_prewarp_func", "(", "self", ".", "alpr_pointer", ",", "prewarp", ")" ]
Updates the prewarp configuration used to skew images in OpenALPR before processing. :param prewarp: A unicode/ascii string (Python 2/3) or bytes array (Python 3) :return: None
[ "Updates", "the", "prewarp", "configuration", "used", "to", "skew", "images", "in", "OpenALPR", "before", "processing", "." ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/alpr/openalpr_fix.py#L241-L250
elsampsa/valkka-live
valkka/mvision/alpr/openalpr_fix.py
Alpr.set_default_region
def set_default_region(self, region): """ This sets the default region for detecting license plates. For example, setting region to "md" for Maryland or "fr" for France. :param region: A unicode/ascii string (Python 2/3) or bytes array (Python 3) :return: None """ ...
python
def set_default_region(self, region): """ This sets the default region for detecting license plates. For example, setting region to "md" for Maryland or "fr" for France. :param region: A unicode/ascii string (Python 2/3) or bytes array (Python 3) :return: None """ ...
[ "def", "set_default_region", "(", "self", ",", "region", ")", ":", "region", "=", "_convert_to_charp", "(", "region", ")", "self", ".", "_set_default_region_func", "(", "self", ".", "alpr_pointer", ",", "region", ")" ]
This sets the default region for detecting license plates. For example, setting region to "md" for Maryland or "fr" for France. :param region: A unicode/ascii string (Python 2/3) or bytes array (Python 3) :return: None
[ "This", "sets", "the", "default", "region", "for", "detecting", "license", "plates", ".", "For", "example", "setting", "region", "to", "md", "for", "Maryland", "or", "fr", "for", "France", "." ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/alpr/openalpr_fix.py#L252-L261
Jaymon/pout
pout/reflect.py
CallString.is_complete
def is_complete(self): """Return True if this call string is complete, meaning it has a function name and balanced parens""" try: [t for t in self.tokens] ret = True logger.debug('CallString [{}] is complete'.format(self.strip())) except tokenize.Toke...
python
def is_complete(self): """Return True if this call string is complete, meaning it has a function name and balanced parens""" try: [t for t in self.tokens] ret = True logger.debug('CallString [{}] is complete'.format(self.strip())) except tokenize.Toke...
[ "def", "is_complete", "(", "self", ")", ":", "try", ":", "[", "t", "for", "t", "in", "self", ".", "tokens", "]", "ret", "=", "True", "logger", ".", "debug", "(", "'CallString [{}] is complete'", ".", "format", "(", "self", ".", "strip", "(", ")", ")"...
Return True if this call string is complete, meaning it has a function name and balanced parens
[ "Return", "True", "if", "this", "call", "string", "is", "complete", "meaning", "it", "has", "a", "function", "name", "and", "balanced", "parens" ]
train
https://github.com/Jaymon/pout/blob/fa71b64384ddeb3b538855ed93e785d9985aad05/pout/reflect.py#L30-L42
Jaymon/pout
pout/reflect.py
Call._find_calls
def _find_calls(self, ast_tree, called_module, called_func): ''' scan the abstract source tree looking for possible ways to call the called_module and called_func since -- 7-2-12 -- Jay example -- # import the module a couple ways: import pout ...
python
def _find_calls(self, ast_tree, called_module, called_func): ''' scan the abstract source tree looking for possible ways to call the called_module and called_func since -- 7-2-12 -- Jay example -- # import the module a couple ways: import pout ...
[ "def", "_find_calls", "(", "self", ",", "ast_tree", ",", "called_module", ",", "called_func", ")", ":", "s", "=", "set", "(", ")", "# always add the default call, the set will make sure there are no dupes...", "s", ".", "add", "(", "\"{}.{}\"", ".", "format", "(", ...
scan the abstract source tree looking for possible ways to call the called_module and called_func since -- 7-2-12 -- Jay example -- # import the module a couple ways: import pout from pout import v from pout import v as voom import p...
[ "scan", "the", "abstract", "source", "tree", "looking", "for", "possible", "ways", "to", "call", "the", "called_module", "and", "called_func" ]
train
https://github.com/Jaymon/pout/blob/fa71b64384ddeb3b538855ed93e785d9985aad05/pout/reflect.py#L277-L339
Jaymon/pout
pout/reflect.py
Reflect._get_arg_info
def _get_arg_info(self): ''' get all the info of a method call this will find what arg names you passed into the method and tie them to their passed in values, it will also find file and line number return -- dict -- a bunch of info on the call ''' ret_dict = { ...
python
def _get_arg_info(self): ''' get all the info of a method call this will find what arg names you passed into the method and tie them to their passed in values, it will also find file and line number return -- dict -- a bunch of info on the call ''' ret_dict = { ...
[ "def", "_get_arg_info", "(", "self", ")", ":", "ret_dict", "=", "{", "'args'", ":", "[", "]", ",", "#'frame': None,", "'line'", ":", "'Unknown'", ",", "'file'", ":", "'Unknown'", ",", "'arg_names'", ":", "[", "]", "}", "arg_vals", "=", "self", ".", "ar...
get all the info of a method call this will find what arg names you passed into the method and tie them to their passed in values, it will also find file and line number return -- dict -- a bunch of info on the call
[ "get", "all", "the", "info", "of", "a", "method", "call" ]
train
https://github.com/Jaymon/pout/blob/fa71b64384ddeb3b538855ed93e785d9985aad05/pout/reflect.py#L368-L405
Jaymon/pout
pout/reflect.py
Reflect._find_entry_call
def _find_entry_call(self, frames): """attempts to auto-discover the correct frame""" back_i = 0 pout_path = self._get_src_file(self.modname) for frame_i, frame in enumerate(frames): if frame[1] == pout_path: back_i = frame_i return Call(frames[back_...
python
def _find_entry_call(self, frames): """attempts to auto-discover the correct frame""" back_i = 0 pout_path = self._get_src_file(self.modname) for frame_i, frame in enumerate(frames): if frame[1] == pout_path: back_i = frame_i return Call(frames[back_...
[ "def", "_find_entry_call", "(", "self", ",", "frames", ")", ":", "back_i", "=", "0", "pout_path", "=", "self", ".", "_get_src_file", "(", "self", ".", "modname", ")", "for", "frame_i", ",", "frame", "in", "enumerate", "(", "frames", ")", ":", "if", "fr...
attempts to auto-discover the correct frame
[ "attempts", "to", "auto", "-", "discover", "the", "correct", "frame" ]
train
https://github.com/Jaymon/pout/blob/fa71b64384ddeb3b538855ed93e785d9985aad05/pout/reflect.py#L425-L434
elsampsa/valkka-live
valkka/mvision/yolo2/base.py
MVisionProcess.postActivate_
def postActivate_(self): """Whatever you need to do after creating the shmem client """ if (self.requiredGPU_MB(self.required_mb)): self.analyzer = YoloV2Analyzer(verbose = self.verbose) else: self.warning_message = "WARNING: not enough GPU memory!" se...
python
def postActivate_(self): """Whatever you need to do after creating the shmem client """ if (self.requiredGPU_MB(self.required_mb)): self.analyzer = YoloV2Analyzer(verbose = self.verbose) else: self.warning_message = "WARNING: not enough GPU memory!" se...
[ "def", "postActivate_", "(", "self", ")", ":", "if", "(", "self", ".", "requiredGPU_MB", "(", "self", ".", "required_mb", ")", ")", ":", "self", ".", "analyzer", "=", "YoloV2Analyzer", "(", "verbose", "=", "self", ".", "verbose", ")", "else", ":", "sel...
Whatever you need to do after creating the shmem client
[ "Whatever", "you", "need", "to", "do", "after", "creating", "the", "shmem", "client" ]
train
https://github.com/elsampsa/valkka-live/blob/218bb2ecf71c516c85b1b6e075454bba13090cd8/valkka/mvision/yolo2/base.py#L71-L78
veripress/veripress
veripress/helpers.py
url_rule
def url_rule(blueprint_or_app, rules, endpoint=None, view_func=None, **options): """ Add one or more url rules to the given Flask blueprint or app. :param blueprint_or_app: Flask blueprint or app :param rules: a single rule string or a list of rules :param endpoint: endpoint :param...
python
def url_rule(blueprint_or_app, rules, endpoint=None, view_func=None, **options): """ Add one or more url rules to the given Flask blueprint or app. :param blueprint_or_app: Flask blueprint or app :param rules: a single rule string or a list of rules :param endpoint: endpoint :param...
[ "def", "url_rule", "(", "blueprint_or_app", ",", "rules", ",", "endpoint", "=", "None", ",", "view_func", "=", "None", ",", "*", "*", "options", ")", ":", "for", "rule", "in", "to_list", "(", "rules", ")", ":", "blueprint_or_app", ".", "add_url_rule", "(...
Add one or more url rules to the given Flask blueprint or app. :param blueprint_or_app: Flask blueprint or app :param rules: a single rule string or a list of rules :param endpoint: endpoint :param view_func: view function :param options: other options
[ "Add", "one", "or", "more", "url", "rules", "to", "the", "given", "Flask", "blueprint", "or", "app", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/helpers.py#L9-L24
veripress/veripress
veripress/helpers.py
to_list
def to_list(item_or_list): """ Convert a single item, a tuple, a generator or anything else to a list. :param item_or_list: single item or iterable to convert :return: a list """ if isinstance(item_or_list, list): return item_or_list elif isinstance(item_or_list, (str, bytes)): ...
python
def to_list(item_or_list): """ Convert a single item, a tuple, a generator or anything else to a list. :param item_or_list: single item or iterable to convert :return: a list """ if isinstance(item_or_list, list): return item_or_list elif isinstance(item_or_list, (str, bytes)): ...
[ "def", "to_list", "(", "item_or_list", ")", ":", "if", "isinstance", "(", "item_or_list", ",", "list", ")", ":", "return", "item_or_list", "elif", "isinstance", "(", "item_or_list", ",", "(", "str", ",", "bytes", ")", ")", ":", "return", "[", "item_or_list...
Convert a single item, a tuple, a generator or anything else to a list. :param item_or_list: single item or iterable to convert :return: a list
[ "Convert", "a", "single", "item", "a", "tuple", "a", "generator", "or", "anything", "else", "to", "a", "list", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/helpers.py#L27-L41
veripress/veripress
veripress/helpers.py
to_datetime
def to_datetime(date_or_datetime): """ Convert a date object to a datetime object, or return as it is if it's not a date object. :param date_or_datetime: date or datetime object :return: a datetime object """ if isinstance(date_or_datetime, date) and \ not isinstance(date_or_dat...
python
def to_datetime(date_or_datetime): """ Convert a date object to a datetime object, or return as it is if it's not a date object. :param date_or_datetime: date or datetime object :return: a datetime object """ if isinstance(date_or_datetime, date) and \ not isinstance(date_or_dat...
[ "def", "to_datetime", "(", "date_or_datetime", ")", ":", "if", "isinstance", "(", "date_or_datetime", ",", "date", ")", "and", "not", "isinstance", "(", "date_or_datetime", ",", "datetime", ")", ":", "d", "=", "date_or_datetime", "return", "datetime", ".", "st...
Convert a date object to a datetime object, or return as it is if it's not a date object. :param date_or_datetime: date or datetime object :return: a datetime object
[ "Convert", "a", "date", "object", "to", "a", "datetime", "object", "or", "return", "as", "it", "is", "if", "it", "s", "not", "a", "date", "object", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/helpers.py#L44-L57
veripress/veripress
veripress/helpers.py
timezone_from_str
def timezone_from_str(tz_str): """ Convert a timezone string to a timezone object. :param tz_str: string with format 'Asia/Shanghai' or 'UTC±[hh]:[mm]' :return: a timezone object (tzinfo) """ m = re.match(r'UTC([+|-]\d{1,2}):(\d{2})', tz_str) if m: # in format 'UTC±[hh]:[mm]' ...
python
def timezone_from_str(tz_str): """ Convert a timezone string to a timezone object. :param tz_str: string with format 'Asia/Shanghai' or 'UTC±[hh]:[mm]' :return: a timezone object (tzinfo) """ m = re.match(r'UTC([+|-]\d{1,2}):(\d{2})', tz_str) if m: # in format 'UTC±[hh]:[mm]' ...
[ "def", "timezone_from_str", "(", "tz_str", ")", ":", "m", "=", "re", ".", "match", "(", "r'UTC([+|-]\\d{1,2}):(\\d{2})'", ",", "tz_str", ")", "if", "m", ":", "# in format 'UTC±[hh]:[mm]'", "delta_h", "=", "int", "(", "m", ".", "group", "(", "1", ")", ")", ...
Convert a timezone string to a timezone object. :param tz_str: string with format 'Asia/Shanghai' or 'UTC±[hh]:[mm]' :return: a timezone object (tzinfo)
[ "Convert", "a", "timezone", "string", "to", "a", "timezone", "object", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/helpers.py#L60-L78
veripress/veripress
veripress/helpers.py
traverse_directory
def traverse_directory(dir_path, yield_dir=False): """ Traverse through a directory recursively. :param dir_path: directory path :param yield_dir: yield subdirectory or not :return: a generator """ if not os.path.isdir(dir_path): return for item in os.listdir(dir_path): ...
python
def traverse_directory(dir_path, yield_dir=False): """ Traverse through a directory recursively. :param dir_path: directory path :param yield_dir: yield subdirectory or not :return: a generator """ if not os.path.isdir(dir_path): return for item in os.listdir(dir_path): ...
[ "def", "traverse_directory", "(", "dir_path", ",", "yield_dir", "=", "False", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "dir_path", ")", ":", "return", "for", "item", "in", "os", ".", "listdir", "(", "dir_path", ")", ":", "new_path",...
Traverse through a directory recursively. :param dir_path: directory path :param yield_dir: yield subdirectory or not :return: a generator
[ "Traverse", "through", "a", "directory", "recursively", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/helpers.py#L143-L161
veripress/veripress
veripress/helpers.py
parse_toc
def parse_toc(html_content): """ Parse TOC of HTML content if the SHOW_TOC config is true. :param html_content: raw HTML content :return: tuple(processed HTML, toc list, toc HTML unordered list) """ from flask import current_app from veripress.model.toc import HtmlTocParser if current_...
python
def parse_toc(html_content): """ Parse TOC of HTML content if the SHOW_TOC config is true. :param html_content: raw HTML content :return: tuple(processed HTML, toc list, toc HTML unordered list) """ from flask import current_app from veripress.model.toc import HtmlTocParser if current_...
[ "def", "parse_toc", "(", "html_content", ")", ":", "from", "flask", "import", "current_app", "from", "veripress", ".", "model", ".", "toc", "import", "HtmlTocParser", "if", "current_app", ".", "config", "[", "'SHOW_TOC'", "]", ":", "toc_parser", "=", "HtmlTocP...
Parse TOC of HTML content if the SHOW_TOC config is true. :param html_content: raw HTML content :return: tuple(processed HTML, toc list, toc HTML unordered list)
[ "Parse", "TOC", "of", "HTML", "content", "if", "the", "SHOW_TOC", "config", "is", "true", "." ]
train
https://github.com/veripress/veripress/blob/9e3df3a10eb1db32da596bf52118fe6acbe4b14a/veripress/helpers.py#L164-L185
Jaymon/pout
pout/utils.py
String.indent
def indent(self, indent_count): ''' add whitespace to the beginning of each line of val link -- http://code.activestate.com/recipes/66055-changing-the-indentation-of-a-multi-line-string/ val -- string indent -- integer -- how much whitespace we want in front of each line of val...
python
def indent(self, indent_count): ''' add whitespace to the beginning of each line of val link -- http://code.activestate.com/recipes/66055-changing-the-indentation-of-a-multi-line-string/ val -- string indent -- integer -- how much whitespace we want in front of each line of val...
[ "def", "indent", "(", "self", ",", "indent_count", ")", ":", "if", "indent_count", "<", "1", ":", "return", "self", "s", "=", "[", "(", "\"\\t\"", "*", "indent_count", ")", "+", "line", "for", "line", "in", "self", ".", "splitlines", "(", "False", ")...
add whitespace to the beginning of each line of val link -- http://code.activestate.com/recipes/66055-changing-the-indentation-of-a-multi-line-string/ val -- string indent -- integer -- how much whitespace we want in front of each line of val return -- string -- val with more whitespa...
[ "add", "whitespace", "to", "the", "beginning", "of", "each", "line", "of", "val" ]
train
https://github.com/Jaymon/pout/blob/fa71b64384ddeb3b538855ed93e785d9985aad05/pout/utils.py#L48-L63