repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
MacHu-GWU/angora-project
angora/crawler/simplecrawler.py
SimpleCrawler.login
def login(self, url, payload): """Performe log in. url is the login page url, for example: https://login.secureserver.net/index.php? payload includes the account and password for example: ``{"loginlist": "YourAccount", "password": "YourPassword"}`` """ self.auth...
python
def login(self, url, payload): """Performe log in. url is the login page url, for example: https://login.secureserver.net/index.php? payload includes the account and password for example: ``{"loginlist": "YourAccount", "password": "YourPassword"}`` """ self.auth...
[ "def", "login", "(", "self", ",", "url", ",", "payload", ")", ":", "self", ".", "auth", "=", "requests", ".", "Session", "(", ")", "try", ":", "self", ".", "auth", ".", "post", "(", "url", ",", "data", "=", "payload", ",", "timeout", "=", "self",...
Performe log in. url is the login page url, for example: https://login.secureserver.net/index.php? payload includes the account and password for example: ``{"loginlist": "YourAccount", "password": "YourPassword"}``
[ "Performe", "log", "in", "." ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/crawler/simplecrawler.py#L149-L164
MacHu-GWU/angora-project
angora/crawler/simplecrawler.py
SimpleCrawler.get_response
def get_response(self, url, timeout=None): """Return http request response. """ if not timeout: timeout = self.default_timeout if self.default_sleeptime: time.sleep(self.default_sleeptime) try: return self.auth.get(url, headers=self.default_h...
python
def get_response(self, url, timeout=None): """Return http request response. """ if not timeout: timeout = self.default_timeout if self.default_sleeptime: time.sleep(self.default_sleeptime) try: return self.auth.get(url, headers=self.default_h...
[ "def", "get_response", "(", "self", ",", "url", ",", "timeout", "=", "None", ")", ":", "if", "not", "timeout", ":", "timeout", "=", "self", ".", "default_timeout", "if", "self", ".", "default_sleeptime", ":", "time", ".", "sleep", "(", "self", ".", "de...
Return http request response.
[ "Return", "http", "request", "response", "." ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/crawler/simplecrawler.py#L171-L183
MacHu-GWU/angora-project
angora/crawler/simplecrawler.py
SimpleCrawler.html_with_encoding
def html_with_encoding(self, url, timeout=None, encoding="utf-8"): """Manually get html with user encoding setting. """ response = self.get_response(url, timeout=timeout) if response: return self.decoder.decode(response.content, encoding)[0] else: return N...
python
def html_with_encoding(self, url, timeout=None, encoding="utf-8"): """Manually get html with user encoding setting. """ response = self.get_response(url, timeout=timeout) if response: return self.decoder.decode(response.content, encoding)[0] else: return N...
[ "def", "html_with_encoding", "(", "self", ",", "url", ",", "timeout", "=", "None", ",", "encoding", "=", "\"utf-8\"", ")", ":", "response", "=", "self", ".", "get_response", "(", "url", ",", "timeout", "=", "timeout", ")", "if", "response", ":", "return"...
Manually get html with user encoding setting.
[ "Manually", "get", "html", "with", "user", "encoding", "setting", "." ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/crawler/simplecrawler.py#L185-L192
MacHu-GWU/angora-project
angora/crawler/simplecrawler.py
SimpleCrawler.html
def html(self, url, timeout=None): """High level method to get http request response in text. smartly handle the encoding problem. """ response = self.get_response(url, timeout=timeout) if response: domain = self.get_domain(url) if domain in self.domain_en...
python
def html(self, url, timeout=None): """High level method to get http request response in text. smartly handle the encoding problem. """ response = self.get_response(url, timeout=timeout) if response: domain = self.get_domain(url) if domain in self.domain_en...
[ "def", "html", "(", "self", ",", "url", ",", "timeout", "=", "None", ")", ":", "response", "=", "self", ".", "get_response", "(", "url", ",", "timeout", "=", "timeout", ")", "if", "response", ":", "domain", "=", "self", ".", "get_domain", "(", "url",...
High level method to get http request response in text. smartly handle the encoding problem.
[ "High", "level", "method", "to", "get", "http", "request", "response", "in", "text", ".", "smartly", "handle", "the", "encoding", "problem", "." ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/crawler/simplecrawler.py#L194-L219
MacHu-GWU/angora-project
angora/crawler/simplecrawler.py
SimpleCrawler.binary
def binary(self, url, timeout=None): """High level method to get http request response in bytes. """ response = self.get_response(url, timeout=timeout) if response: return response.content else: return None
python
def binary(self, url, timeout=None): """High level method to get http request response in bytes. """ response = self.get_response(url, timeout=timeout) if response: return response.content else: return None
[ "def", "binary", "(", "self", ",", "url", ",", "timeout", "=", "None", ")", ":", "response", "=", "self", ".", "get_response", "(", "url", ",", "timeout", "=", "timeout", ")", "if", "response", ":", "return", "response", ".", "content", "else", ":", ...
High level method to get http request response in bytes.
[ "High", "level", "method", "to", "get", "http", "request", "response", "in", "bytes", "." ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/crawler/simplecrawler.py#L221-L228
MacHu-GWU/angora-project
angora/crawler/simplecrawler.py
SimpleCrawler.download
def download(self, url, dst, timeout=None): """Download the binary file at url to distination path. """ response = self.get_response(url, timeout=timeout) if response: with open(dst, "wb") as f: for block in response.iter_content(1024): if ...
python
def download(self, url, dst, timeout=None): """Download the binary file at url to distination path. """ response = self.get_response(url, timeout=timeout) if response: with open(dst, "wb") as f: for block in response.iter_content(1024): if ...
[ "def", "download", "(", "self", ",", "url", ",", "dst", ",", "timeout", "=", "None", ")", ":", "response", "=", "self", ".", "get_response", "(", "url", ",", "timeout", "=", "timeout", ")", "if", "response", ":", "with", "open", "(", "dst", ",", "\...
Download the binary file at url to distination path.
[ "Download", "the", "binary", "file", "at", "url", "to", "distination", "path", "." ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/crawler/simplecrawler.py#L230-L239
za-creature/gulpless
gulpless/handlers.py
Handler.handles
def handles(self, src, path): """Must return a list of files that this handler will produce after successfully processing `path`. If the current handler does not operate on `path`, None should be returned. If instead `path` should not produce output by itself (but should be compiled none...
python
def handles(self, src, path): """Must return a list of files that this handler will produce after successfully processing `path`. If the current handler does not operate on `path`, None should be returned. If instead `path` should not produce output by itself (but should be compiled none...
[ "def", "handles", "(", "self", ",", "src", ",", "path", ")", ":", "if", "not", "pathtools", ".", "patterns", ".", "match_path", "(", "path", ",", "self", ".", "patterns", ",", "self", ".", "ignore_patterns", ")", ":", "return", "None", "return", "self"...
Must return a list of files that this handler will produce after successfully processing `path`. If the current handler does not operate on `path`, None should be returned. If instead `path` should not produce output by itself (but should be compiled nonetheless), then an empty list shou...
[ "Must", "return", "a", "list", "of", "files", "that", "this", "handler", "will", "produce", "after", "successfully", "processing", "path", ".", "If", "the", "current", "handler", "does", "not", "operate", "on", "path", "None", "should", "be", "returned", "."...
train
https://github.com/za-creature/gulpless/blob/fd73907dbe86880086719816bb042233f85121f6/gulpless/handlers.py#L40-L53
za-creature/gulpless
gulpless/handlers.py
Handler.changed
def changed(self, src, path, dest): """Called whenever `path` is changed in the source folder `src`. `dest` is the output folder. The default implementation calls `build` after determining that the input file is newer than any of the outputs, or any of the outputs does not exist.""" ...
python
def changed(self, src, path, dest): """Called whenever `path` is changed in the source folder `src`. `dest` is the output folder. The default implementation calls `build` after determining that the input file is newer than any of the outputs, or any of the outputs does not exist.""" ...
[ "def", "changed", "(", "self", ",", "src", ",", "path", ",", "dest", ")", ":", "try", ":", "mtime", "=", "os", ".", "path", ".", "getmtime", "(", "os", ".", "path", ".", "join", "(", "src", ",", "path", ")", ")", "self", ".", "_build", "(", "...
Called whenever `path` is changed in the source folder `src`. `dest` is the output folder. The default implementation calls `build` after determining that the input file is newer than any of the outputs, or any of the outputs does not exist.
[ "Called", "whenever", "path", "is", "changed", "in", "the", "source", "folder", "src", ".", "dest", "is", "the", "output", "folder", ".", "The", "default", "implementation", "calls", "build", "after", "determining", "that", "the", "input", "file", "is", "new...
train
https://github.com/za-creature/gulpless/blob/fd73907dbe86880086719816bb042233f85121f6/gulpless/handlers.py#L58-L70
za-creature/gulpless
gulpless/handlers.py
Handler._build
def _build(self, src, path, dest, mtime): """Calls `build` after testing that at least one output file (as returned by `_outputs()` does not exist or is older than `mtime`. If the build fails, the build time is recorded and no other builds will be attempted on `input` until this method i...
python
def _build(self, src, path, dest, mtime): """Calls `build` after testing that at least one output file (as returned by `_outputs()` does not exist or is older than `mtime`. If the build fails, the build time is recorded and no other builds will be attempted on `input` until this method i...
[ "def", "_build", "(", "self", ",", "src", ",", "path", ",", "dest", ",", "mtime", ")", ":", "input_path", "=", "os", ".", "path", ".", "join", "(", "src", ",", "path", ")", "output_paths", "=", "[", "os", ".", "path", ".", "join", "(", "dest", ...
Calls `build` after testing that at least one output file (as returned by `_outputs()` does not exist or is older than `mtime`. If the build fails, the build time is recorded and no other builds will be attempted on `input` until this method is called with a larger mtime.
[ "Calls", "build", "after", "testing", "that", "at", "least", "one", "output", "file", "(", "as", "returned", "by", "_outputs", "()", "does", "not", "exist", "or", "is", "older", "than", "mtime", ".", "If", "the", "build", "fails", "the", "build", "time",...
train
https://github.com/za-creature/gulpless/blob/fd73907dbe86880086719816bb042233f85121f6/gulpless/handlers.py#L75-L126
za-creature/gulpless
gulpless/handlers.py
Handler.build
def build(self, input_path, output_paths): """Should be extended by subclasses to actually do stuff. By default this will copy `input` over every file in the `outputs` list.""" for output in output_paths: shutil.copy(input_path, output_paths)
python
def build(self, input_path, output_paths): """Should be extended by subclasses to actually do stuff. By default this will copy `input` over every file in the `outputs` list.""" for output in output_paths: shutil.copy(input_path, output_paths)
[ "def", "build", "(", "self", ",", "input_path", ",", "output_paths", ")", ":", "for", "output", "in", "output_paths", ":", "shutil", ".", "copy", "(", "input_path", ",", "output_paths", ")" ]
Should be extended by subclasses to actually do stuff. By default this will copy `input` over every file in the `outputs` list.
[ "Should", "be", "extended", "by", "subclasses", "to", "actually", "do", "stuff", ".", "By", "default", "this", "will", "copy", "input", "over", "every", "file", "in", "the", "outputs", "list", "." ]
train
https://github.com/za-creature/gulpless/blob/fd73907dbe86880086719816bb042233f85121f6/gulpless/handlers.py#L128-L132
za-creature/gulpless
gulpless/handlers.py
TreeHandler.rebuild_references
def rebuild_references(self, src, path, reject=None): """Updates `parents` and `children` to be in sync with the changes to `src` if any.""" if reject is None: reject = set() reject.add(path) try: filename = os.path.join(src, path) mtime = os....
python
def rebuild_references(self, src, path, reject=None): """Updates `parents` and `children` to be in sync with the changes to `src` if any.""" if reject is None: reject = set() reject.add(path) try: filename = os.path.join(src, path) mtime = os....
[ "def", "rebuild_references", "(", "self", ",", "src", ",", "path", ",", "reject", "=", "None", ")", ":", "if", "reject", "is", "None", ":", "reject", "=", "set", "(", ")", "reject", ".", "add", "(", "path", ")", "try", ":", "filename", "=", "os", ...
Updates `parents` and `children` to be in sync with the changes to `src` if any.
[ "Updates", "parents", "and", "children", "to", "be", "in", "sync", "with", "the", "changes", "to", "src", "if", "any", "." ]
train
https://github.com/za-creature/gulpless/blob/fd73907dbe86880086719816bb042233f85121f6/gulpless/handlers.py#L150-L204
za-creature/gulpless
gulpless/handlers.py
TreeHandler.deleted
def deleted(self, src, path): """Update the reference tree when a handled file is deleted.""" if self.parents[path] is not None: for parent in self.parents[path]: self.children[parent].remove(path) if not self.children[parent]: del self.chi...
python
def deleted(self, src, path): """Update the reference tree when a handled file is deleted.""" if self.parents[path] is not None: for parent in self.parents[path]: self.children[parent].remove(path) if not self.children[parent]: del self.chi...
[ "def", "deleted", "(", "self", ",", "src", ",", "path", ")", ":", "if", "self", ".", "parents", "[", "path", "]", "is", "not", "None", ":", "for", "parent", "in", "self", ".", "parents", "[", "path", "]", ":", "self", ".", "children", "[", "paren...
Update the reference tree when a handled file is deleted.
[ "Update", "the", "reference", "tree", "when", "a", "handled", "file", "is", "deleted", "." ]
train
https://github.com/za-creature/gulpless/blob/fd73907dbe86880086719816bb042233f85121f6/gulpless/handlers.py#L233-L240
za-creature/gulpless
gulpless/handlers.py
TreeHandler.changed
def changed(self, src, path, dest): """If `path` does not have any parents, it is built. Otherwise, it will attempt to build every parent of `path` (or their parents). Output file modification times are taken into account to prevent unnecessary builds.""" modified = {path: self.p...
python
def changed(self, src, path, dest): """If `path` does not have any parents, it is built. Otherwise, it will attempt to build every parent of `path` (or their parents). Output file modification times are taken into account to prevent unnecessary builds.""" modified = {path: self.p...
[ "def", "changed", "(", "self", ",", "src", ",", "path", ",", "dest", ")", ":", "modified", "=", "{", "path", ":", "self", ".", "parents", "[", "path", "]", ".", "updated", "}", "while", "True", ":", "for", "path", "in", "modified", ":", "if", "se...
If `path` does not have any parents, it is built. Otherwise, it will attempt to build every parent of `path` (or their parents). Output file modification times are taken into account to prevent unnecessary builds.
[ "If", "path", "does", "not", "have", "any", "parents", "it", "is", "built", ".", "Otherwise", "it", "will", "attempt", "to", "build", "every", "parent", "of", "path", "(", "or", "their", "parents", ")", ".", "Output", "file", "modification", "times", "ar...
train
https://github.com/za-creature/gulpless/blob/fd73907dbe86880086719816bb042233f85121f6/gulpless/handlers.py#L242-L261
kyan001/PyKyanToolKit
KyanToolKit.py
KyanToolKit.inTrace
def inTrace(self, func: callable): # decorator """将被修饰函数的进入和退出写入日志""" @wraps(func) def call(*args, **kwargs): self.TRACE("Enter " + func.__qualname__ + "()") result = func(*args, **kwargs) self.TRACE("Leave " + func.__qualname__ + "()") return res...
python
def inTrace(self, func: callable): # decorator """将被修饰函数的进入和退出写入日志""" @wraps(func) def call(*args, **kwargs): self.TRACE("Enter " + func.__qualname__ + "()") result = func(*args, **kwargs) self.TRACE("Leave " + func.__qualname__ + "()") return res...
[ "def", "inTrace", "(", "self", ",", "func", ":", "callable", ")", ":", "# decorator", "@", "wraps", "(", "func", ")", "def", "call", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "TRACE", "(", "\"Enter \"", "+", "func", ".", "...
将被修饰函数的进入和退出写入日志
[ "将被修饰函数的进入和退出写入日志" ]
train
https://github.com/kyan001/PyKyanToolKit/blob/a3974fcd45ce41f743b4a3d42af961fedea8fda8/KyanToolKit.py#L29-L37
kyan001/PyKyanToolKit
KyanToolKit.py
KyanToolKit.banner
def banner(cls, content_="Well Come"): """生成占3行的字符串""" # char def sp_char = "#" # length calc itsays = content_.strip() effective_length = int(len(itsays)) # gen contents side_space = ' ' * int(effective_length * ((1 - 0.618) / 0.618) / 2) content_...
python
def banner(cls, content_="Well Come"): """生成占3行的字符串""" # char def sp_char = "#" # length calc itsays = content_.strip() effective_length = int(len(itsays)) # gen contents side_space = ' ' * int(effective_length * ((1 - 0.618) / 0.618) / 2) content_...
[ "def", "banner", "(", "cls", ",", "content_", "=", "\"Well Come\"", ")", ":", "# char def", "sp_char", "=", "\"#\"", "# length calc", "itsays", "=", "content_", ".", "strip", "(", ")", "effective_length", "=", "int", "(", "len", "(", "itsays", ")", ")", ...
生成占3行的字符串
[ "生成占3行的字符串" ]
train
https://github.com/kyan001/PyKyanToolKit/blob/a3974fcd45ce41f743b4a3d42af961fedea8fda8/KyanToolKit.py#L41-L53
kyan001/PyKyanToolKit
KyanToolKit.py
KyanToolKit.imageToColor
def imageToColor(url: str, scale=200, mode='rgb'): """将 url 指向的图片提纯为一个颜色""" from PIL import Image import colorsys if url: response = urllib.request.urlopen(url) img_buffer = io.BytesIO(response.read()) img = Image.open(img_buffer) img = img...
python
def imageToColor(url: str, scale=200, mode='rgb'): """将 url 指向的图片提纯为一个颜色""" from PIL import Image import colorsys if url: response = urllib.request.urlopen(url) img_buffer = io.BytesIO(response.read()) img = Image.open(img_buffer) img = img...
[ "def", "imageToColor", "(", "url", ":", "str", ",", "scale", "=", "200", ",", "mode", "=", "'rgb'", ")", ":", "from", "PIL", "import", "Image", "import", "colorsys", "if", "url", ":", "response", "=", "urllib", ".", "request", ".", "urlopen", "(", "u...
将 url 指向的图片提纯为一个颜色
[ "将", "url", "指向的图片提纯为一个颜色" ]
train
https://github.com/kyan001/PyKyanToolKit/blob/a3974fcd45ce41f743b4a3d42af961fedea8fda8/KyanToolKit.py#L63-L94
kyan001/PyKyanToolKit
KyanToolKit.py
KyanToolKit.clearScreen
def clearScreen(cls): """Clear the screen""" if "win32" in sys.platform: os.system('cls') elif "linux" in sys.platform: os.system('clear') elif 'darwin' in sys.platform: os.system('clear') else: cit.err("No clearScreen for " + sys.p...
python
def clearScreen(cls): """Clear the screen""" if "win32" in sys.platform: os.system('cls') elif "linux" in sys.platform: os.system('clear') elif 'darwin' in sys.platform: os.system('clear') else: cit.err("No clearScreen for " + sys.p...
[ "def", "clearScreen", "(", "cls", ")", ":", "if", "\"win32\"", "in", "sys", ".", "platform", ":", "os", ".", "system", "(", "'cls'", ")", "elif", "\"linux\"", "in", "sys", ".", "platform", ":", "os", ".", "system", "(", "'clear'", ")", "elif", "'darw...
Clear the screen
[ "Clear", "the", "screen" ]
train
https://github.com/kyan001/PyKyanToolKit/blob/a3974fcd45ce41f743b4a3d42af961fedea8fda8/KyanToolKit.py#L98-L107
kyan001/PyKyanToolKit
KyanToolKit.py
KyanToolKit.getPyCmd
def getPyCmd(cls): """get OS's python command""" if "win32" in sys.platform: return 'py' elif "linux" in sys.platform: return 'python3' elif 'darwin' in sys.platform: return 'python3' else: cit.err("No python3 command for " + sys.pl...
python
def getPyCmd(cls): """get OS's python command""" if "win32" in sys.platform: return 'py' elif "linux" in sys.platform: return 'python3' elif 'darwin' in sys.platform: return 'python3' else: cit.err("No python3 command for " + sys.pl...
[ "def", "getPyCmd", "(", "cls", ")", ":", "if", "\"win32\"", "in", "sys", ".", "platform", ":", "return", "'py'", "elif", "\"linux\"", "in", "sys", ".", "platform", ":", "return", "'python3'", "elif", "'darwin'", "in", "sys", ".", "platform", ":", "return...
get OS's python command
[ "get", "OS", "s", "python", "command" ]
train
https://github.com/kyan001/PyKyanToolKit/blob/a3974fcd45ce41f743b4a3d42af961fedea8fda8/KyanToolKit.py#L110-L119
kyan001/PyKyanToolKit
KyanToolKit.py
KyanToolKit.runCmd
def runCmd(cls, cmd): """run command and show if success or failed Args: cmd: string Returns: bool: if this command run successfully """ cit.echo(cmd, "command") result = os.system(cmd) cls.checkResult(result)
python
def runCmd(cls, cmd): """run command and show if success or failed Args: cmd: string Returns: bool: if this command run successfully """ cit.echo(cmd, "command") result = os.system(cmd) cls.checkResult(result)
[ "def", "runCmd", "(", "cls", ",", "cmd", ")", ":", "cit", ".", "echo", "(", "cmd", ",", "\"command\"", ")", "result", "=", "os", ".", "system", "(", "cmd", ")", "cls", ".", "checkResult", "(", "result", ")" ]
run command and show if success or failed Args: cmd: string Returns: bool: if this command run successfully
[ "run", "command", "and", "show", "if", "success", "or", "failed" ]
train
https://github.com/kyan001/PyKyanToolKit/blob/a3974fcd45ce41f743b4a3d42af961fedea8fda8/KyanToolKit.py#L123-L133
kyan001/PyKyanToolKit
KyanToolKit.py
KyanToolKit.readCmd
def readCmd(cls, cmd): """run command and return the str format stdout Args: cmd: string Returns: str: what the command's echo """ args = shlex.split(cmd) proc = subprocess.Popen(args, stdout=subprocess.PIPE) (proc_stdout, proc_stderr) = p...
python
def readCmd(cls, cmd): """run command and return the str format stdout Args: cmd: string Returns: str: what the command's echo """ args = shlex.split(cmd) proc = subprocess.Popen(args, stdout=subprocess.PIPE) (proc_stdout, proc_stderr) = p...
[ "def", "readCmd", "(", "cls", ",", "cmd", ")", ":", "args", "=", "shlex", ".", "split", "(", "cmd", ")", "proc", "=", "subprocess", ".", "Popen", "(", "args", ",", "stdout", "=", "subprocess", ".", "PIPE", ")", "(", "proc_stdout", ",", "proc_stderr",...
run command and return the str format stdout Args: cmd: string Returns: str: what the command's echo
[ "run", "command", "and", "return", "the", "str", "format", "stdout" ]
train
https://github.com/kyan001/PyKyanToolKit/blob/a3974fcd45ce41f743b4a3d42af961fedea8fda8/KyanToolKit.py#L137-L148
kyan001/PyKyanToolKit
KyanToolKit.py
KyanToolKit.updateFile
def updateFile(cls, file_, url): """Check and update file compares with remote_url Args: file_: str. Local filename. Normally it's __file__ url: str. Remote url of raw file content. Normally it's https://raw.github.com/... Returns: bool: file updated or not ...
python
def updateFile(cls, file_, url): """Check and update file compares with remote_url Args: file_: str. Local filename. Normally it's __file__ url: str. Remote url of raw file content. Normally it's https://raw.github.com/... Returns: bool: file updated or not ...
[ "def", "updateFile", "(", "cls", ",", "file_", ",", "url", ")", ":", "def", "compare", "(", "s1", ",", "s2", ")", ":", "return", "s1", "==", "s2", ",", "len", "(", "s2", ")", "-", "len", "(", "s1", ")", "if", "not", "url", "or", "not", "file_...
Check and update file compares with remote_url Args: file_: str. Local filename. Normally it's __file__ url: str. Remote url of raw file content. Normally it's https://raw.github.com/... Returns: bool: file updated or not
[ "Check", "and", "update", "file", "compares", "with", "remote_url" ]
train
https://github.com/kyan001/PyKyanToolKit/blob/a3974fcd45ce41f743b4a3d42af961fedea8fda8/KyanToolKit.py#L151-L186
kyan001/PyKyanToolKit
KyanToolKit.py
KyanToolKit.ajax
def ajax(cls, url, param={}, method='get'): """Get info by ajax Args: url: string Returns: dict: json decoded into a dict """ param = urllib.parse.urlencode(param) if method.lower() == 'get': req = urllib.request.Request(url + '?' + pa...
python
def ajax(cls, url, param={}, method='get'): """Get info by ajax Args: url: string Returns: dict: json decoded into a dict """ param = urllib.parse.urlencode(param) if method.lower() == 'get': req = urllib.request.Request(url + '?' + pa...
[ "def", "ajax", "(", "cls", ",", "url", ",", "param", "=", "{", "}", ",", "method", "=", "'get'", ")", ":", "param", "=", "urllib", ".", "parse", ".", "urlencode", "(", "param", ")", "if", "method", ".", "lower", "(", ")", "==", "'get'", ":", "r...
Get info by ajax Args: url: string Returns: dict: json decoded into a dict
[ "Get", "info", "by", "ajax" ]
train
https://github.com/kyan001/PyKyanToolKit/blob/a3974fcd45ce41f743b4a3d42af961fedea8fda8/KyanToolKit.py#L190-L211
kyan001/PyKyanToolKit
KyanToolKit.py
KyanToolKit.readFile
def readFile(cls, filepath): """Try different encoding to open a file in readonly mode""" for mode in ("utf-8", 'gbk', 'cp1252', 'windows-1252', 'latin-1'): try: with open(filepath, mode='r', encoding=mode) as f: content = f.read() cit....
python
def readFile(cls, filepath): """Try different encoding to open a file in readonly mode""" for mode in ("utf-8", 'gbk', 'cp1252', 'windows-1252', 'latin-1'): try: with open(filepath, mode='r', encoding=mode) as f: content = f.read() cit....
[ "def", "readFile", "(", "cls", ",", "filepath", ")", ":", "for", "mode", "in", "(", "\"utf-8\"", ",", "'gbk'", ",", "'cp1252'", ",", "'windows-1252'", ",", "'latin-1'", ")", ":", "try", ":", "with", "open", "(", "filepath", ",", "mode", "=", "'r'", "...
Try different encoding to open a file in readonly mode
[ "Try", "different", "encoding", "to", "open", "a", "file", "in", "readonly", "mode" ]
train
https://github.com/kyan001/PyKyanToolKit/blob/a3974fcd45ce41f743b4a3d42af961fedea8fda8/KyanToolKit.py#L214-L224
pacificclimate/cfmeta
cfmeta/path.py
get_dir_meta
def get_dir_meta(fp, atts): """Pop path information and map to supplied atts """ # Attibutes are popped from deepest directory first atts.reverse() dirname = os.path.split(fp)[0] meta = dirname.split('/') res = {} try: for key in atts: res[key] = meta.pop() ex...
python
def get_dir_meta(fp, atts): """Pop path information and map to supplied atts """ # Attibutes are popped from deepest directory first atts.reverse() dirname = os.path.split(fp)[0] meta = dirname.split('/') res = {} try: for key in atts: res[key] = meta.pop() ex...
[ "def", "get_dir_meta", "(", "fp", ",", "atts", ")", ":", "# Attibutes are popped from deepest directory first", "atts", ".", "reverse", "(", ")", "dirname", "=", "os", ".", "path", ".", "split", "(", "fp", ")", "[", "0", "]", "meta", "=", "dirname", ".", ...
Pop path information and map to supplied atts
[ "Pop", "path", "information", "and", "map", "to", "supplied", "atts" ]
train
https://github.com/pacificclimate/cfmeta/blob/a6eef78d0bce523bb44920ba96233f034b60316a/cfmeta/path.py#L10-L28
krukas/Trionyx
trionyx/trionyx/context_processors.py
trionyx
def trionyx(request): """Add trionyx context data""" return { 'TX_APP_NAME': settings.TX_APP_NAME, 'TX_LOGO_NAME_START': settings.TX_LOGO_NAME_START, 'TX_LOGO_NAME_END': settings.TX_LOGO_NAME_END, 'TX_LOGO_NAME_SMALL_START': settings.TX_LOGO_NAME_SMALL_START, 'TX_LOGO_NAM...
python
def trionyx(request): """Add trionyx context data""" return { 'TX_APP_NAME': settings.TX_APP_NAME, 'TX_LOGO_NAME_START': settings.TX_LOGO_NAME_START, 'TX_LOGO_NAME_END': settings.TX_LOGO_NAME_END, 'TX_LOGO_NAME_SMALL_START': settings.TX_LOGO_NAME_SMALL_START, 'TX_LOGO_NAM...
[ "def", "trionyx", "(", "request", ")", ":", "return", "{", "'TX_APP_NAME'", ":", "settings", ".", "TX_APP_NAME", ",", "'TX_LOGO_NAME_START'", ":", "settings", ".", "TX_LOGO_NAME_START", ",", "'TX_LOGO_NAME_END'", ":", "settings", ".", "TX_LOGO_NAME_END", ",", "'TX...
Add trionyx context data
[ "Add", "trionyx", "context", "data" ]
train
https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/trionyx/context_processors.py#L12-L22
funkybob/antfarm
antfarm/views/urls.py
url_dispatcher.register
def register(self, pattern, view=None): '''Allow decorator-style construction of URL pattern lists.''' if view is None: return partial(self.register, pattern) self.patterns.append(self._make_url((pattern, view))) return view
python
def register(self, pattern, view=None): '''Allow decorator-style construction of URL pattern lists.''' if view is None: return partial(self.register, pattern) self.patterns.append(self._make_url((pattern, view))) return view
[ "def", "register", "(", "self", ",", "pattern", ",", "view", "=", "None", ")", ":", "if", "view", "is", "None", ":", "return", "partial", "(", "self", ".", "register", ",", "pattern", ")", "self", ".", "patterns", ".", "append", "(", "self", ".", "...
Allow decorator-style construction of URL pattern lists.
[ "Allow", "decorator", "-", "style", "construction", "of", "URL", "pattern", "lists", "." ]
train
https://github.com/funkybob/antfarm/blob/40a7cc450eba09a280b7bc8f7c68a807b0177c62/antfarm/views/urls.py#L56-L61
krukas/Trionyx
trionyx/models.py
BaseModel.get_fields
def get_fields(cls, inlcude_base=False, include_id=False): """Get model fields""" for field in cls._meta.fields: if field.name == 'deleted': continue if not include_id and field.name == 'id': continue if not inlcude_base and field.name ...
python
def get_fields(cls, inlcude_base=False, include_id=False): """Get model fields""" for field in cls._meta.fields: if field.name == 'deleted': continue if not include_id and field.name == 'id': continue if not inlcude_base and field.name ...
[ "def", "get_fields", "(", "cls", ",", "inlcude_base", "=", "False", ",", "include_id", "=", "False", ")", ":", "for", "field", "in", "cls", ".", "_meta", ".", "fields", ":", "if", "field", ".", "name", "==", "'deleted'", ":", "continue", "if", "not", ...
Get model fields
[ "Get", "model", "fields" ]
train
https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/models.py#L60-L69
krukas/Trionyx
trionyx/models.py
BaseModel.get_absolute_url
def get_absolute_url(self): """Get model url""" return reverse('trionyx:model-view', kwargs={ 'app': self._meta.app_label, 'model': self._meta.model_name, 'pk': self.id })
python
def get_absolute_url(self): """Get model url""" return reverse('trionyx:model-view', kwargs={ 'app': self._meta.app_label, 'model': self._meta.model_name, 'pk': self.id })
[ "def", "get_absolute_url", "(", "self", ")", ":", "return", "reverse", "(", "'trionyx:model-view'", ",", "kwargs", "=", "{", "'app'", ":", "self", ".", "_meta", ".", "app_label", ",", "'model'", ":", "self", ".", "_meta", ".", "model_name", ",", "'pk'", ...
Get model url
[ "Get", "model", "url" ]
train
https://github.com/krukas/Trionyx/blob/edac132cc0797190153f2e60bc7e88cb50e80da6/trionyx/models.py#L78-L84
francbartoli/marmee
marmee/utils/parser.py
Stac.parse
def parse(self): """Parse an asset from Earth Engine to STAC item Raises: ValueError -- If asset is not of type Image or ImageCollection Returns: Item -- STAC feature of the Google Earth Engine Asset Collection -- STAC collection of the Google Earth Engine A...
python
def parse(self): """Parse an asset from Earth Engine to STAC item Raises: ValueError -- If asset is not of type Image or ImageCollection Returns: Item -- STAC feature of the Google Earth Engine Asset Collection -- STAC collection of the Google Earth Engine A...
[ "def", "parse", "(", "self", ")", ":", "if", "self", ".", "type", "==", "TOKEN_TYPE", "[", "0", "]", "[", "1", "]", ":", "try", ":", "return", "Item", "(", "item_id", "=", "self", ".", "_link", "(", "None", ",", "None", ")", "[", "1", "]", ",...
Parse an asset from Earth Engine to STAC item Raises: ValueError -- If asset is not of type Image or ImageCollection Returns: Item -- STAC feature of the Google Earth Engine Asset Collection -- STAC collection of the Google Earth Engine Asset
[ "Parse", "an", "asset", "from", "Earth", "Engine", "to", "STAC", "item" ]
train
https://github.com/francbartoli/marmee/blob/f971adc84636629b9afbe79c917b74cac81fabf2/marmee/utils/parser.py#L40-L83
francois-vincent/clingon
examples/example1.py
clized_default_shorts
def clized_default_shorts(p1, p2, first_option='default_value', second_option=5, third_option=[4, 3], last_option=False): """Help docstring """ print('%s %s %s %s %s %s' % (p1, p2, first_option, second_op...
python
def clized_default_shorts(p1, p2, first_option='default_value', second_option=5, third_option=[4, 3], last_option=False): """Help docstring """ print('%s %s %s %s %s %s' % (p1, p2, first_option, second_op...
[ "def", "clized_default_shorts", "(", "p1", ",", "p2", ",", "first_option", "=", "'default_value'", ",", "second_option", "=", "5", ",", "third_option", "=", "[", "4", ",", "3", "]", ",", "last_option", "=", "False", ")", ":", "print", "(", "'%s %s %s %s %s...
Help docstring
[ "Help", "docstring" ]
train
https://github.com/francois-vincent/clingon/blob/afc9db073dbc72b2562ce3e444152986a555dcbf/examples/example1.py#L14-L21
Stufinite/cphelper
cphelper/views.py
CourseOfDept
def CourseOfDept(request): """ Generate list of obligatory and optional course of specific Dept. """ dept = request.GET['dept'] school = request.GET['school'] c = Course(school=school) return JsonResponse(c.getByDept(dept=dept, grade=request.GET['grade'] if 'grade' in request.GET else None), safe=False)
python
def CourseOfDept(request): """ Generate list of obligatory and optional course of specific Dept. """ dept = request.GET['dept'] school = request.GET['school'] c = Course(school=school) return JsonResponse(c.getByDept(dept=dept, grade=request.GET['grade'] if 'grade' in request.GET else None), safe=False)
[ "def", "CourseOfDept", "(", "request", ")", ":", "dept", "=", "request", ".", "GET", "[", "'dept'", "]", "school", "=", "request", ".", "GET", "[", "'school'", "]", "c", "=", "Course", "(", "school", "=", "school", ")", "return", "JsonResponse", "(", ...
Generate list of obligatory and optional course of specific Dept.
[ "Generate", "list", "of", "obligatory", "and", "optional", "course", "of", "specific", "Dept", "." ]
train
https://github.com/Stufinite/cphelper/blob/ae70f928ae8d65f7a62ed8b8e2836bcc777c5eac/cphelper/views.py#L37-L44
Stufinite/cphelper
cphelper/views.py
CourseOfTime
def CourseOfTime(request): """ Generate list of obligatory and optional course of specific Dept. """ day = request.GET['day'] time = request.GET['time'] school = request.GET['school'] dept = request.GET['dept'].split() c = Course(school=school) return JsonResponse(c.getByTime(day=day, time=time, deptArr=dept)...
python
def CourseOfTime(request): """ Generate list of obligatory and optional course of specific Dept. """ day = request.GET['day'] time = request.GET['time'] school = request.GET['school'] dept = request.GET['dept'].split() c = Course(school=school) return JsonResponse(c.getByTime(day=day, time=time, deptArr=dept)...
[ "def", "CourseOfTime", "(", "request", ")", ":", "day", "=", "request", ".", "GET", "[", "'day'", "]", "time", "=", "request", ".", "GET", "[", "'time'", "]", "school", "=", "request", ".", "GET", "[", "'school'", "]", "dept", "=", "request", ".", ...
Generate list of obligatory and optional course of specific Dept.
[ "Generate", "list", "of", "obligatory", "and", "optional", "course", "of", "specific", "Dept", "." ]
train
https://github.com/Stufinite/cphelper/blob/ae70f928ae8d65f7a62ed8b8e2836bcc777c5eac/cphelper/views.py#L47-L56
Stufinite/cphelper
cphelper/views.py
Genra
def Genra(request): """ Generate dict of Dept and its grade. """ school = request.GET['school'] c = Course(school=school) return JsonResponse(c.getGenra(), safe=False)
python
def Genra(request): """ Generate dict of Dept and its grade. """ school = request.GET['school'] c = Course(school=school) return JsonResponse(c.getGenra(), safe=False)
[ "def", "Genra", "(", "request", ")", ":", "school", "=", "request", ".", "GET", "[", "'school'", "]", "c", "=", "Course", "(", "school", "=", "school", ")", "return", "JsonResponse", "(", "c", ".", "getGenra", "(", ")", ",", "safe", "=", "False", "...
Generate dict of Dept and its grade.
[ "Generate", "dict", "of", "Dept", "and", "its", "grade", "." ]
train
https://github.com/Stufinite/cphelper/blob/ae70f928ae8d65f7a62ed8b8e2836bcc777c5eac/cphelper/views.py#L59-L65
esterhui/pypu
pypu/service_wp.py
service_wp._connectToWP
def _connectToWP(self): """Establish the actual TCP connection to Flickr""" if self.connected_to_wp: logger.debug("Already connected to wp") return True # Load config from file info=json.load(open(WP_LOGIN_FILE,'r')) self.wp = Client(info['url'],\ ...
python
def _connectToWP(self): """Establish the actual TCP connection to Flickr""" if self.connected_to_wp: logger.debug("Already connected to wp") return True # Load config from file info=json.load(open(WP_LOGIN_FILE,'r')) self.wp = Client(info['url'],\ ...
[ "def", "_connectToWP", "(", "self", ")", ":", "if", "self", ".", "connected_to_wp", ":", "logger", ".", "debug", "(", "\"Already connected to wp\"", ")", "return", "True", "# Load config from file", "info", "=", "json", ".", "load", "(", "open", "(", "WP_LOGIN...
Establish the actual TCP connection to Flickr
[ "Establish", "the", "actual", "TCP", "connection", "to", "Flickr" ]
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_wp.py#L46-L63
esterhui/pypu
pypu/service_wp.py
service_wp.Upload
def Upload(self,directory,filename): """Uploads/Updates/Replaces files""" db = self._loadDB(directory) logger.debug("wp: Attempting upload of %s"%(filename)) # See if this already exists in our DB if db.has_key(filename): pid=db[filename] logger.debug('...
python
def Upload(self,directory,filename): """Uploads/Updates/Replaces files""" db = self._loadDB(directory) logger.debug("wp: Attempting upload of %s"%(filename)) # See if this already exists in our DB if db.has_key(filename): pid=db[filename] logger.debug('...
[ "def", "Upload", "(", "self", ",", "directory", ",", "filename", ")", ":", "db", "=", "self", ".", "_loadDB", "(", "directory", ")", "logger", ".", "debug", "(", "\"wp: Attempting upload of %s\"", "%", "(", "filename", ")", ")", "# See if this already exists i...
Uploads/Updates/Replaces files
[ "Uploads", "/", "Updates", "/", "Replaces", "files" ]
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_wp.py#L81-L125
esterhui/pypu
pypu/service_wp.py
service_wp._readMetaAndContent
def _readMetaAndContent(self,fid): """Reads meta data and content from file into WordPressPost() class. Returns the class If error, returns None """ found_meta_separator=False d={} # Read lines until we find the meta separator while found_meta_separator ...
python
def _readMetaAndContent(self,fid): """Reads meta data and content from file into WordPressPost() class. Returns the class If error, returns None """ found_meta_separator=False d={} # Read lines until we find the meta separator while found_meta_separator ...
[ "def", "_readMetaAndContent", "(", "self", ",", "fid", ")", ":", "found_meta_separator", "=", "False", "d", "=", "{", "}", "# Read lines until we find the meta separator", "while", "found_meta_separator", "is", "False", ":", "line", "=", "fid", ".", "readline", "(...
Reads meta data and content from file into WordPressPost() class. Returns the class If error, returns None
[ "Reads", "meta", "data", "and", "content", "from", "file", "into", "WordPressPost", "()", "class", ".", "Returns", "the", "class" ]
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_wp.py#L127-L170
esterhui/pypu
pypu/service_wp.py
service_wp.Remove
def Remove(self,directory,filename): """Deletes post from wordpress""" db = self._loadDB(directory) logger.debug("wp: Attempting to remove %s from wp"%(filename)) # See if this already exists in our DB if db.has_key(filename): pid=db[filename] logger.de...
python
def Remove(self,directory,filename): """Deletes post from wordpress""" db = self._loadDB(directory) logger.debug("wp: Attempting to remove %s from wp"%(filename)) # See if this already exists in our DB if db.has_key(filename): pid=db[filename] logger.de...
[ "def", "Remove", "(", "self", ",", "directory", ",", "filename", ")", ":", "db", "=", "self", ".", "_loadDB", "(", "directory", ")", "logger", ".", "debug", "(", "\"wp: Attempting to remove %s from wp\"", "%", "(", "filename", ")", ")", "# See if this already ...
Deletes post from wordpress
[ "Deletes", "post", "from", "wordpress" ]
train
https://github.com/esterhui/pypu/blob/cc3e259d59f024c2c4c0fbb9c8a1547e51de75ec/pypu/service_wp.py#L172-L194
sbuss/pypercube
pypercube/expression.py
EventExpression.eq
def eq(self, event_property, value): """An equals filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.eq('path', '/') >>> print(filtered) request(elapsed_ms).eq(path, "/") """ c = self.copy() c.filters.app...
python
def eq(self, event_property, value): """An equals filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.eq('path', '/') >>> print(filtered) request(elapsed_ms).eq(path, "/") """ c = self.copy() c.filters.app...
[ "def", "eq", "(", "self", ",", "event_property", ",", "value", ")", ":", "c", "=", "self", ".", "copy", "(", ")", "c", ".", "filters", ".", "append", "(", "filters", ".", "EQ", "(", "event_property", ",", "value", ")", ")", "return", "c" ]
An equals filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.eq('path', '/') >>> print(filtered) request(elapsed_ms).eq(path, "/")
[ "An", "equals", "filter", "chain", "." ]
train
https://github.com/sbuss/pypercube/blob/e9d2cca9c004b8bad6d1e0b68b080f887a186a22/pypercube/expression.py#L238-L248
sbuss/pypercube
pypercube/expression.py
EventExpression.ne
def ne(self, event_property, value): """A not-equal filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.ne('path', '/') >>> print(filtered) request(elapsed_ms).ne(path, "/") """ c = self.copy() c.filters.a...
python
def ne(self, event_property, value): """A not-equal filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.ne('path', '/') >>> print(filtered) request(elapsed_ms).ne(path, "/") """ c = self.copy() c.filters.a...
[ "def", "ne", "(", "self", ",", "event_property", ",", "value", ")", ":", "c", "=", "self", ".", "copy", "(", ")", "c", ".", "filters", ".", "append", "(", "filters", ".", "NE", "(", "event_property", ",", "value", ")", ")", "return", "c" ]
A not-equal filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.ne('path', '/') >>> print(filtered) request(elapsed_ms).ne(path, "/")
[ "A", "not", "-", "equal", "filter", "chain", "." ]
train
https://github.com/sbuss/pypercube/blob/e9d2cca9c004b8bad6d1e0b68b080f887a186a22/pypercube/expression.py#L250-L260
sbuss/pypercube
pypercube/expression.py
EventExpression.lt
def lt(self, event_property, value): """A less-than filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.lt('elapsed_ms', 500) >>> print(filtered) request(elapsed_ms).lt(elapsed_ms, 500) """ c = self.copy() ...
python
def lt(self, event_property, value): """A less-than filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.lt('elapsed_ms', 500) >>> print(filtered) request(elapsed_ms).lt(elapsed_ms, 500) """ c = self.copy() ...
[ "def", "lt", "(", "self", ",", "event_property", ",", "value", ")", ":", "c", "=", "self", ".", "copy", "(", ")", "c", ".", "filters", ".", "append", "(", "filters", ".", "LT", "(", "event_property", ",", "value", ")", ")", "return", "c" ]
A less-than filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.lt('elapsed_ms', 500) >>> print(filtered) request(elapsed_ms).lt(elapsed_ms, 500)
[ "A", "less", "-", "than", "filter", "chain", "." ]
train
https://github.com/sbuss/pypercube/blob/e9d2cca9c004b8bad6d1e0b68b080f887a186a22/pypercube/expression.py#L262-L272
sbuss/pypercube
pypercube/expression.py
EventExpression.le
def le(self, event_property, value): """A less-than-or-equal-to filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.le('elapsed_ms', 500) >>> print(filtered) request(elapsed_ms).le(elapsed_ms, 500) """ c = self.co...
python
def le(self, event_property, value): """A less-than-or-equal-to filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.le('elapsed_ms', 500) >>> print(filtered) request(elapsed_ms).le(elapsed_ms, 500) """ c = self.co...
[ "def", "le", "(", "self", ",", "event_property", ",", "value", ")", ":", "c", "=", "self", ".", "copy", "(", ")", "c", ".", "filters", ".", "append", "(", "filters", ".", "LE", "(", "event_property", ",", "value", ")", ")", "return", "c" ]
A less-than-or-equal-to filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.le('elapsed_ms', 500) >>> print(filtered) request(elapsed_ms).le(elapsed_ms, 500)
[ "A", "less", "-", "than", "-", "or", "-", "equal", "-", "to", "filter", "chain", "." ]
train
https://github.com/sbuss/pypercube/blob/e9d2cca9c004b8bad6d1e0b68b080f887a186a22/pypercube/expression.py#L274-L284
sbuss/pypercube
pypercube/expression.py
EventExpression.gt
def gt(self, event_property, value): """A greater-than filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.gt('elapsed_ms', 500) >>> print(filtered) request(elapsed_ms).gt(elapsed_ms, 500) """ c = self.copy() ...
python
def gt(self, event_property, value): """A greater-than filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.gt('elapsed_ms', 500) >>> print(filtered) request(elapsed_ms).gt(elapsed_ms, 500) """ c = self.copy() ...
[ "def", "gt", "(", "self", ",", "event_property", ",", "value", ")", ":", "c", "=", "self", ".", "copy", "(", ")", "c", ".", "filters", ".", "append", "(", "filters", ".", "GT", "(", "event_property", ",", "value", ")", ")", "return", "c" ]
A greater-than filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.gt('elapsed_ms', 500) >>> print(filtered) request(elapsed_ms).gt(elapsed_ms, 500)
[ "A", "greater", "-", "than", "filter", "chain", "." ]
train
https://github.com/sbuss/pypercube/blob/e9d2cca9c004b8bad6d1e0b68b080f887a186a22/pypercube/expression.py#L286-L296
sbuss/pypercube
pypercube/expression.py
EventExpression.ge
def ge(self, event_property, value): """A greater-than-or-equal-to filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.ge('elapsed_ms', 500) >>> print(filtered) request(elapsed_ms).ge(elapsed_ms, 500) """ c = self...
python
def ge(self, event_property, value): """A greater-than-or-equal-to filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.ge('elapsed_ms', 500) >>> print(filtered) request(elapsed_ms).ge(elapsed_ms, 500) """ c = self...
[ "def", "ge", "(", "self", ",", "event_property", ",", "value", ")", ":", "c", "=", "self", ".", "copy", "(", ")", "c", ".", "filters", ".", "append", "(", "filters", ".", "GE", "(", "event_property", ",", "value", ")", ")", "return", "c" ]
A greater-than-or-equal-to filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.ge('elapsed_ms', 500) >>> print(filtered) request(elapsed_ms).ge(elapsed_ms, 500)
[ "A", "greater", "-", "than", "-", "or", "-", "equal", "-", "to", "filter", "chain", "." ]
train
https://github.com/sbuss/pypercube/blob/e9d2cca9c004b8bad6d1e0b68b080f887a186a22/pypercube/expression.py#L298-L308
sbuss/pypercube
pypercube/expression.py
EventExpression.re
def re(self, event_property, value): """A regular expression filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.re('path', '[^A-Za-z0-9+]') >>> print(filtered) request(elapsed_ms).re(path, "[^A-Za-z0-9+]") """ c ...
python
def re(self, event_property, value): """A regular expression filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.re('path', '[^A-Za-z0-9+]') >>> print(filtered) request(elapsed_ms).re(path, "[^A-Za-z0-9+]") """ c ...
[ "def", "re", "(", "self", ",", "event_property", ",", "value", ")", ":", "c", "=", "self", ".", "copy", "(", ")", "c", ".", "filters", ".", "append", "(", "filters", ".", "RE", "(", "event_property", ",", "value", ")", ")", "return", "c" ]
A regular expression filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.re('path', '[^A-Za-z0-9+]') >>> print(filtered) request(elapsed_ms).re(path, "[^A-Za-z0-9+]")
[ "A", "regular", "expression", "filter", "chain", "." ]
train
https://github.com/sbuss/pypercube/blob/e9d2cca9c004b8bad6d1e0b68b080f887a186a22/pypercube/expression.py#L310-L320
sbuss/pypercube
pypercube/expression.py
EventExpression.startswith
def startswith(self, event_property, value): """A starts-with filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.startswith('path', '/cube') >>> print(filtered) request(elapsed_ms).re(path, "^/cube") """ c = self...
python
def startswith(self, event_property, value): """A starts-with filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.startswith('path', '/cube') >>> print(filtered) request(elapsed_ms).re(path, "^/cube") """ c = self...
[ "def", "startswith", "(", "self", ",", "event_property", ",", "value", ")", ":", "c", "=", "self", ".", "copy", "(", ")", "c", ".", "filters", ".", "append", "(", "filters", ".", "RE", "(", "event_property", ",", "\"^{value}\"", ".", "format", "(", "...
A starts-with filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.startswith('path', '/cube') >>> print(filtered) request(elapsed_ms).re(path, "^/cube")
[ "A", "starts", "-", "with", "filter", "chain", "." ]
train
https://github.com/sbuss/pypercube/blob/e9d2cca9c004b8bad6d1e0b68b080f887a186a22/pypercube/expression.py#L322-L333
sbuss/pypercube
pypercube/expression.py
EventExpression.in_array
def in_array(self, event_property, value): """An in-array filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.in_array('path', '/event') >>> print(filtered) request(elapsed_ms).in(path, ["/", "e", "v", "e", "n", "t"]) >>>...
python
def in_array(self, event_property, value): """An in-array filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.in_array('path', '/event') >>> print(filtered) request(elapsed_ms).in(path, ["/", "e", "v", "e", "n", "t"]) >>>...
[ "def", "in_array", "(", "self", ",", "event_property", ",", "value", ")", ":", "c", "=", "self", ".", "copy", "(", ")", "c", ".", "filters", ".", "append", "(", "filters", ".", "IN", "(", "event_property", ",", "value", ")", ")", "return", "c" ]
An in-array filter chain. >>> request_time = EventExpression('request', 'elapsed_ms') >>> filtered = request_time.in_array('path', '/event') >>> print(filtered) request(elapsed_ms).in(path, ["/", "e", "v", "e", "n", "t"]) >>> filtered = request_time.in_array('path', ['/event', '...
[ "An", "in", "-", "array", "filter", "chain", "." ]
train
https://github.com/sbuss/pypercube/blob/e9d2cca9c004b8bad6d1e0b68b080f887a186a22/pypercube/expression.py#L361-L374
openp2pdesign/makerlabs
makerlabs/timeline.py
get_multiple_data
def get_multiple_data(): """Get data from all the platforms listed in makerlabs.""" # Get data from all the mapped platforms all_labs = {} all_labs["diybio_org"] = diybio_org.get_labs(format="dict") all_labs["fablabs_io"] = fablabs_io.get_labs(format="dict") all_labs["makeinitaly_foundation"] =...
python
def get_multiple_data(): """Get data from all the platforms listed in makerlabs.""" # Get data from all the mapped platforms all_labs = {} all_labs["diybio_org"] = diybio_org.get_labs(format="dict") all_labs["fablabs_io"] = fablabs_io.get_labs(format="dict") all_labs["makeinitaly_foundation"] =...
[ "def", "get_multiple_data", "(", ")", ":", "# Get data from all the mapped platforms", "all_labs", "=", "{", "}", "all_labs", "[", "\"diybio_org\"", "]", "=", "diybio_org", ".", "get_labs", "(", "format", "=", "\"dict\"", ")", "all_labs", "[", "\"fablabs_io\"", "]...
Get data from all the platforms listed in makerlabs.
[ "Get", "data", "from", "all", "the", "platforms", "listed", "in", "makerlabs", "." ]
train
https://github.com/openp2pdesign/makerlabs/blob/b5838440174f10d370abb671358db9a99d7739fd/makerlabs/timeline.py#L24-L39
openp2pdesign/makerlabs
makerlabs/timeline.py
get_timeline
def get_timeline(source): """Rebuild a timeline of the history of makerlabs.""" # Set up the pandas timeseries dataframe timeline_format = ["name", "type", "source", "country", "city", "latitude", "longitude", "website_url", "twitter_url", "facebook_page_url", ...
python
def get_timeline(source): """Rebuild a timeline of the history of makerlabs.""" # Set up the pandas timeseries dataframe timeline_format = ["name", "type", "source", "country", "city", "latitude", "longitude", "website_url", "twitter_url", "facebook_page_url", ...
[ "def", "get_timeline", "(", "source", ")", ":", "# Set up the pandas timeseries dataframe", "timeline_format", "=", "[", "\"name\"", ",", "\"type\"", ",", "\"source\"", ",", "\"country\"", ",", "\"city\"", ",", "\"latitude\"", ",", "\"longitude\"", ",", "\"website_url...
Rebuild a timeline of the history of makerlabs.
[ "Rebuild", "a", "timeline", "of", "the", "history", "of", "makerlabs", "." ]
train
https://github.com/openp2pdesign/makerlabs/blob/b5838440174f10d370abb671358db9a99d7739fd/makerlabs/timeline.py#L42-L105
edwards-lab/libGWAS
libgwas/transposed_pedigree_parser.py
Parser.load_genotypes
def load_genotypes(self): """This really just intializes the file by opening it up. """ if DataParser.compressed_pedigree: self.genotype_file = gzip.open("%s.gz" % self.tped_file, 'rb') else: self.genotype_file = open(self.tped_file) self.filter_missing()
python
def load_genotypes(self): """This really just intializes the file by opening it up. """ if DataParser.compressed_pedigree: self.genotype_file = gzip.open("%s.gz" % self.tped_file, 'rb') else: self.genotype_file = open(self.tped_file) self.filter_missing()
[ "def", "load_genotypes", "(", "self", ")", ":", "if", "DataParser", ".", "compressed_pedigree", ":", "self", ".", "genotype_file", "=", "gzip", ".", "open", "(", "\"%s.gz\"", "%", "self", ".", "tped_file", ",", "'rb'", ")", "else", ":", "self", ".", "gen...
This really just intializes the file by opening it up.
[ "This", "really", "just", "intializes", "the", "file", "by", "opening", "it", "up", "." ]
train
https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/transposed_pedigree_parser.py#L105-L112
edwards-lab/libGWAS
libgwas/transposed_pedigree_parser.py
Parser.process_genotypes
def process_genotypes(self, data): """Parse pedigree line and remove excluded individuals from geno Translates alleles into numerical genotypes (0, 1, 2) counting number of minor alleles. Throws exceptions if an there are not 2 distinct alleles """ # Get a list of uni...
python
def process_genotypes(self, data): """Parse pedigree line and remove excluded individuals from geno Translates alleles into numerical genotypes (0, 1, 2) counting number of minor alleles. Throws exceptions if an there are not 2 distinct alleles """ # Get a list of uni...
[ "def", "process_genotypes", "(", "self", ",", "data", ")", ":", "# Get a list of uniq entries in the data, except for missing", "alleles", "=", "list", "(", "set", "(", "data", "[", "4", ":", "]", ")", "-", "set", "(", "DataParser", ".", "missing_representation", ...
Parse pedigree line and remove excluded individuals from geno Translates alleles into numerical genotypes (0, 1, 2) counting number of minor alleles. Throws exceptions if an there are not 2 distinct alleles
[ "Parse", "pedigree", "line", "and", "remove", "excluded", "individuals", "from", "geno" ]
train
https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/transposed_pedigree_parser.py#L114-L165
edwards-lab/libGWAS
libgwas/transposed_pedigree_parser.py
Parser.filter_missing
def filter_missing(self): """Filter out individuals and SNPs that have too many missing to be considered""" missing = None locus_count = 0 # Filter out individuals according to missingness self.genotype_file.seek(0) for genotypes in self.genotype_fil...
python
def filter_missing(self): """Filter out individuals and SNPs that have too many missing to be considered""" missing = None locus_count = 0 # Filter out individuals according to missingness self.genotype_file.seek(0) for genotypes in self.genotype_fil...
[ "def", "filter_missing", "(", "self", ")", ":", "missing", "=", "None", "locus_count", "=", "0", "# Filter out individuals according to missingness", "self", ".", "genotype_file", ".", "seek", "(", "0", ")", "for", "genotypes", "in", "self", ".", "genotype_file", ...
Filter out individuals and SNPs that have too many missing to be considered
[ "Filter", "out", "individuals", "and", "SNPs", "that", "have", "too", "many", "missing", "to", "be", "considered" ]
train
https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/transposed_pedigree_parser.py#L167-L211
edwards-lab/libGWAS
libgwas/transposed_pedigree_parser.py
Parser.populate_iteration
def populate_iteration(self, iteration): """Pour the current data into the iteration object""" cur_idx = iteration.cur_idx genotypes = self.genotype_file.next().split() iteration.chr, iteration.rsid, junk, iteration.pos = genotypes[0:4] iteration.chr = int(iteration.chr) ...
python
def populate_iteration(self, iteration): """Pour the current data into the iteration object""" cur_idx = iteration.cur_idx genotypes = self.genotype_file.next().split() iteration.chr, iteration.rsid, junk, iteration.pos = genotypes[0:4] iteration.chr = int(iteration.chr) ...
[ "def", "populate_iteration", "(", "self", ",", "iteration", ")", ":", "cur_idx", "=", "iteration", ".", "cur_idx", "genotypes", "=", "self", ".", "genotype_file", ".", "next", "(", ")", ".", "split", "(", ")", "iteration", ".", "chr", ",", "iteration", "...
Pour the current data into the iteration object
[ "Pour", "the", "current", "data", "into", "the", "iteration", "object" ]
train
https://github.com/edwards-lab/libGWAS/blob/d68c9a083d443dfa5d7c5112de29010909cfe23f/libgwas/transposed_pedigree_parser.py#L215-L238
openp2pdesign/makerlabs
makerlabs/nesta.py
get_labs
def get_labs(format): """Gets current UK Makerspaces data as listed by NESTA.""" ukmakerspaces_data = data_from_nesta() ukmakerspaces = {} # Iterate over csv rows for index, row in ukmakerspaces_data.iterrows(): current_lab = UKMakerspace() current_lab.address_1 = row["Address"].re...
python
def get_labs(format): """Gets current UK Makerspaces data as listed by NESTA.""" ukmakerspaces_data = data_from_nesta() ukmakerspaces = {} # Iterate over csv rows for index, row in ukmakerspaces_data.iterrows(): current_lab = UKMakerspace() current_lab.address_1 = row["Address"].re...
[ "def", "get_labs", "(", "format", ")", ":", "ukmakerspaces_data", "=", "data_from_nesta", "(", ")", "ukmakerspaces", "=", "{", "}", "# Iterate over csv rows", "for", "index", ",", "row", "in", "ukmakerspaces_data", ".", "iterrows", "(", ")", ":", "current_lab", ...
Gets current UK Makerspaces data as listed by NESTA.
[ "Gets", "current", "UK", "Makerspaces", "data", "as", "listed", "by", "NESTA", "." ]
train
https://github.com/openp2pdesign/makerlabs/blob/b5838440174f10d370abb671358db9a99d7739fd/makerlabs/nesta.py#L47-L105
datakortet/dkfileutils
dkfileutils/pfind.py
pfindall
def pfindall(path, *fnames): """Find all fnames in the closest ancestor directory. For the purposes of this function, we are our own closest ancestor. I.e. given the structure:: . `-- a |-- b | |-- c | | `-- x.txt ...
python
def pfindall(path, *fnames): """Find all fnames in the closest ancestor directory. For the purposes of this function, we are our own closest ancestor. I.e. given the structure:: . `-- a |-- b | |-- c | | `-- x.txt ...
[ "def", "pfindall", "(", "path", ",", "*", "fnames", ")", ":", "wd", "=", "os", ".", "path", ".", "abspath", "(", "path", ")", "assert", "os", ".", "path", ".", "isdir", "(", "wd", ")", "def", "parents", "(", ")", ":", "\"\"\"yield successive parent d...
Find all fnames in the closest ancestor directory. For the purposes of this function, we are our own closest ancestor. I.e. given the structure:: . `-- a |-- b | |-- c | | `-- x.txt | `-- x.txt ...
[ "Find", "all", "fnames", "in", "the", "closest", "ancestor", "directory", ".", "For", "the", "purposes", "of", "this", "function", "we", "are", "our", "own", "closest", "ancestor", ".", "I", ".", "e", ".", "given", "the", "structure", "::" ]
train
https://github.com/datakortet/dkfileutils/blob/924098d6e2edf88ad9b3ffdec9c74530f80a7d77/dkfileutils/pfind.py#L10-L56
baverman/supplement
supplement/hooks/pygtk/__init__.py
PyGtkHintProvider.get_function_params
def get_function_params(self, scope_path, pyfunc): """:type pyfunc: rope.base.pyobjectsdef.PyFunction""" pyclass = pyfunc.parent scope_path = get_attribute_scope_path(pyclass) glade_file = self.get_glade_file_for_class(scope_path, pyclass) if glade_file: self.proces...
python
def get_function_params(self, scope_path, pyfunc): """:type pyfunc: rope.base.pyobjectsdef.PyFunction""" pyclass = pyfunc.parent scope_path = get_attribute_scope_path(pyclass) glade_file = self.get_glade_file_for_class(scope_path, pyclass) if glade_file: self.proces...
[ "def", "get_function_params", "(", "self", ",", "scope_path", ",", "pyfunc", ")", ":", "pyclass", "=", "pyfunc", ".", "parent", "scope_path", "=", "get_attribute_scope_path", "(", "pyclass", ")", "glade_file", "=", "self", ".", "get_glade_file_for_class", "(", "...
:type pyfunc: rope.base.pyobjectsdef.PyFunction
[ ":", "type", "pyfunc", ":", "rope", ".", "base", ".", "pyobjectsdef", ".", "PyFunction" ]
train
https://github.com/baverman/supplement/blob/955002fe5a5749c9f0d89002f0006ec4fcd35bc9/supplement/hooks/pygtk/__init__.py#L315-L326
baverman/supplement
supplement/hooks/pygtk/__init__.py
PyGtkHintProvider.get_params_for_handler
def get_params_for_handler(self, class_scope, pyfunc): """:type pyfunc: rope.base.pyobjectsdef.PyFunction""" try: cls, signal = self.handlers[class_scope][pyfunc.get_name()] except KeyError: return {} attrs = {} idx = 0 names = pyfunc.get_param_n...
python
def get_params_for_handler(self, class_scope, pyfunc): """:type pyfunc: rope.base.pyobjectsdef.PyFunction""" try: cls, signal = self.handlers[class_scope][pyfunc.get_name()] except KeyError: return {} attrs = {} idx = 0 names = pyfunc.get_param_n...
[ "def", "get_params_for_handler", "(", "self", ",", "class_scope", ",", "pyfunc", ")", ":", "try", ":", "cls", ",", "signal", "=", "self", ".", "handlers", "[", "class_scope", "]", "[", "pyfunc", ".", "get_name", "(", ")", "]", "except", "KeyError", ":", ...
:type pyfunc: rope.base.pyobjectsdef.PyFunction
[ ":", "type", "pyfunc", ":", "rope", ".", "base", ".", "pyobjectsdef", ".", "PyFunction" ]
train
https://github.com/baverman/supplement/blob/955002fe5a5749c9f0d89002f0006ec4fcd35bc9/supplement/hooks/pygtk/__init__.py#L328-L359
rmorshea/dstruct
dstruct/dstruct.py
datafield
def datafield(*path, **kwargs): """A decorator that defines a field for data within a :class:`DataStruct` The decorated function becomes the parser for a :class:`DataField` which will be assigned to a data structure under the function's defined name. Parameters ---------- path: tuple T...
python
def datafield(*path, **kwargs): """A decorator that defines a field for data within a :class:`DataStruct` The decorated function becomes the parser for a :class:`DataField` which will be assigned to a data structure under the function's defined name. Parameters ---------- path: tuple T...
[ "def", "datafield", "(", "*", "path", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "path", ")", "==", "1", "and", "isinstance", "(", "path", "[", "0", "]", ",", "types", ".", "FunctionType", ")", ":", "return", "DataField", "(", "*", "*",...
A decorator that defines a field for data within a :class:`DataStruct` The decorated function becomes the parser for a :class:`DataField` which will be assigned to a data structure under the function's defined name. Parameters ---------- path: tuple The path to a value within a raw piece o...
[ "A", "decorator", "that", "defines", "a", "field", "for", "data", "within", "a", ":", "class", ":", "DataStruct" ]
train
https://github.com/rmorshea/dstruct/blob/c5eec8ac659c0846835e35ce1f59e7c3f9c9f25c/dstruct/dstruct.py#L272-L291
rmorshea/dstruct
dstruct/dstruct.py
BaseDescriptor.init_self
def init_self(self, cls, name): """Initialize this descriptor instance Parameters ---------- cls : class The class which owns this descriptor name : str The attribute name of this descriptor """ # the class the descriptor is defined on ...
python
def init_self(self, cls, name): """Initialize this descriptor instance Parameters ---------- cls : class The class which owns this descriptor name : str The attribute name of this descriptor """ # the class the descriptor is defined on ...
[ "def", "init_self", "(", "self", ",", "cls", ",", "name", ")", ":", "# the class the descriptor is defined on", "self", ".", "this_class", "=", "cls", "# the attribute name of this descriptor", "self", ".", "this_name", "=", "name" ]
Initialize this descriptor instance Parameters ---------- cls : class The class which owns this descriptor name : str The attribute name of this descriptor
[ "Initialize", "this", "descriptor", "instance" ]
train
https://github.com/rmorshea/dstruct/blob/c5eec8ac659c0846835e35ce1f59e7c3f9c9f25c/dstruct/dstruct.py#L31-L44
rmorshea/dstruct
dstruct/dstruct.py
DataStruct.add_fields
def add_fields(self, **fields): """Add new data fields to this struct instance""" self.__class__ = type(self.__class__.__name__, (self.__class__,), fields) for k, v in fields.items(): v.init_inst(self)
python
def add_fields(self, **fields): """Add new data fields to this struct instance""" self.__class__ = type(self.__class__.__name__, (self.__class__,), fields) for k, v in fields.items(): v.init_inst(self)
[ "def", "add_fields", "(", "self", ",", "*", "*", "fields", ")", ":", "self", ".", "__class__", "=", "type", "(", "self", ".", "__class__", ".", "__name__", ",", "(", "self", ".", "__class__", ",", ")", ",", "fields", ")", "for", "k", ",", "v", "i...
Add new data fields to this struct instance
[ "Add", "new", "data", "fields", "to", "this", "struct", "instance" ]
train
https://github.com/rmorshea/dstruct/blob/c5eec8ac659c0846835e35ce1f59e7c3f9c9f25c/dstruct/dstruct.py#L357-L362
rmorshea/dstruct
dstruct/dstruct.py
DataStruct.del_fields
def del_fields(self, *names): """Delete data fields from this struct instance""" cls = type(self) self.__class__ = cls for n in names: # don't raise error if a field is absent if isinstance(getattr(cls, n, None), DataField): if n in self._field_val...
python
def del_fields(self, *names): """Delete data fields from this struct instance""" cls = type(self) self.__class__ = cls for n in names: # don't raise error if a field is absent if isinstance(getattr(cls, n, None), DataField): if n in self._field_val...
[ "def", "del_fields", "(", "self", ",", "*", "names", ")", ":", "cls", "=", "type", "(", "self", ")", "self", ".", "__class__", "=", "cls", "for", "n", "in", "names", ":", "# don't raise error if a field is absent", "if", "isinstance", "(", "getattr", "(", ...
Delete data fields from this struct instance
[ "Delete", "data", "fields", "from", "this", "struct", "instance" ]
train
https://github.com/rmorshea/dstruct/blob/c5eec8ac659c0846835e35ce1f59e7c3f9c9f25c/dstruct/dstruct.py#L364-L373
rmorshea/dstruct
dstruct/dstruct.py
DataStruct.set_field
def set_field(self, name, value): """Forcibly sets field values without parsing""" f = getattr(self, name, None) if isinstance(f, DataField): f.set(self, value) else: raise FieldError("No field named '%s'" % name)
python
def set_field(self, name, value): """Forcibly sets field values without parsing""" f = getattr(self, name, None) if isinstance(f, DataField): f.set(self, value) else: raise FieldError("No field named '%s'" % name)
[ "def", "set_field", "(", "self", ",", "name", ",", "value", ")", ":", "f", "=", "getattr", "(", "self", ",", "name", ",", "None", ")", "if", "isinstance", "(", "f", ",", "DataField", ")", ":", "f", ".", "set", "(", "self", ",", "value", ")", "e...
Forcibly sets field values without parsing
[ "Forcibly", "sets", "field", "values", "without", "parsing" ]
train
https://github.com/rmorshea/dstruct/blob/c5eec8ac659c0846835e35ce1f59e7c3f9c9f25c/dstruct/dstruct.py#L375-L381
DallasMorningNews/django-datafreezer
datafreezer/views_compat.py
LoginView.get_success_url
def get_success_url(self): """Ensure the user-originating redirection URL is safe.""" redirect_to = self.request.POST.get( self.redirect_field_name, self.request.GET.get(self.redirect_field_name, '') ) url_is_safe = is_safe_url( url=redirect_to, ...
python
def get_success_url(self): """Ensure the user-originating redirection URL is safe.""" redirect_to = self.request.POST.get( self.redirect_field_name, self.request.GET.get(self.redirect_field_name, '') ) url_is_safe = is_safe_url( url=redirect_to, ...
[ "def", "get_success_url", "(", "self", ")", ":", "redirect_to", "=", "self", ".", "request", ".", "POST", ".", "get", "(", "self", ".", "redirect_field_name", ",", "self", ".", "request", ".", "GET", ".", "get", "(", "self", ".", "redirect_field_name", "...
Ensure the user-originating redirection URL is safe.
[ "Ensure", "the", "user", "-", "originating", "redirection", "URL", "is", "safe", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views_compat.py#L61-L74
DallasMorningNews/django-datafreezer
datafreezer/views_compat.py
LoginView.form_valid
def form_valid(self, form): """Security check complete. Log the user in.""" auth_login(self.request, form.get_user()) return HttpResponseRedirect(self.get_success_url())
python
def form_valid(self, form): """Security check complete. Log the user in.""" auth_login(self.request, form.get_user()) return HttpResponseRedirect(self.get_success_url())
[ "def", "form_valid", "(", "self", ",", "form", ")", ":", "auth_login", "(", "self", ".", "request", ",", "form", ".", "get_user", "(", ")", ")", "return", "HttpResponseRedirect", "(", "self", ".", "get_success_url", "(", ")", ")" ]
Security check complete. Log the user in.
[ "Security", "check", "complete", ".", "Log", "the", "user", "in", "." ]
train
https://github.com/DallasMorningNews/django-datafreezer/blob/982dcf2015c80a280f1a093e32977cb71d4ea7aa/datafreezer/views_compat.py#L79-L82
MacHu-GWU/angora-project
angora/baseclass/defaultExc.py
declare_base
def declare_base(erroName=True): """Create a Exception with default message. :param errorName: boolean, True if you want the Exception name in the error message body. """ if erroName: class Base(Exception): def __str__(self): if len(self.args): ...
python
def declare_base(erroName=True): """Create a Exception with default message. :param errorName: boolean, True if you want the Exception name in the error message body. """ if erroName: class Base(Exception): def __str__(self): if len(self.args): ...
[ "def", "declare_base", "(", "erroName", "=", "True", ")", ":", "if", "erroName", ":", "class", "Base", "(", "Exception", ")", ":", "def", "__str__", "(", "self", ")", ":", "if", "len", "(", "self", ".", "args", ")", ":", "return", "\"%s: %s\"", "%", ...
Create a Exception with default message. :param errorName: boolean, True if you want the Exception name in the error message body.
[ "Create", "a", "Exception", "with", "default", "message", ".", ":", "param", "errorName", ":", "boolean", "True", "if", "you", "want", "the", "Exception", "name", "in", "the", "error", "message", "body", "." ]
train
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/baseclass/defaultExc.py#L4-L24
pignacio/issue2branch
issue2branch/trackers/base.py
IssueTracker._request
def _request(self, method, url, **kwargs): ''' Wrap `utils.requests.request` adding user and password. ''' self._ask_for_password() return request(method, url, user=self._user, password=self._password, **kwargs)
python
def _request(self, method, url, **kwargs): ''' Wrap `utils.requests.request` adding user and password. ''' self._ask_for_password() return request(method, url, user=self._user, password=self._password, **kwargs)
[ "def", "_request", "(", "self", ",", "method", ",", "url", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_ask_for_password", "(", ")", "return", "request", "(", "method", ",", "url", ",", "user", "=", "self", ".", "_user", ",", "password", "=", ...
Wrap `utils.requests.request` adding user and password.
[ "Wrap", "utils", ".", "requests", ".", "request", "adding", "user", "and", "password", "." ]
train
https://github.com/pignacio/issue2branch/blob/f1a581d93df017f7ec4ad2d432b254a4a3b8c131/issue2branch/trackers/base.py#L38-L42
inveniosoftware-contrib/record-recommender
record_recommender/profiles.py
Profiles.create
def create(self, weeks): """Create the user and ip profiles for the given weeks.""" user_pageviews = self.create_profiles('Pageviews', weeks) user_downloads = self.create_profiles('Downloads', weeks) self._export_profiles('Profiles', user_pageviews, user_downloads) user_pagevie...
python
def create(self, weeks): """Create the user and ip profiles for the given weeks.""" user_pageviews = self.create_profiles('Pageviews', weeks) user_downloads = self.create_profiles('Downloads', weeks) self._export_profiles('Profiles', user_pageviews, user_downloads) user_pagevie...
[ "def", "create", "(", "self", ",", "weeks", ")", ":", "user_pageviews", "=", "self", ".", "create_profiles", "(", "'Pageviews'", ",", "weeks", ")", "user_downloads", "=", "self", ".", "create_profiles", "(", "'Downloads'", ",", "weeks", ")", "self", ".", "...
Create the user and ip profiles for the given weeks.
[ "Create", "the", "user", "and", "ip", "profiles", "for", "the", "given", "weeks", "." ]
train
https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/profiles.py#L54-L65
inveniosoftware-contrib/record-recommender
record_recommender/profiles.py
Profiles._export_profiles
def _export_profiles(self, profile_name, user_pageviews, user_downloads, ip_user=False): """Filter and export the user profiles.""" views_min = self.config.get('user_views_min') views_max = self.config.get('user_views_max') ip_user_id = 500000000000 add_u...
python
def _export_profiles(self, profile_name, user_pageviews, user_downloads, ip_user=False): """Filter and export the user profiles.""" views_min = self.config.get('user_views_min') views_max = self.config.get('user_views_max') ip_user_id = 500000000000 add_u...
[ "def", "_export_profiles", "(", "self", ",", "profile_name", ",", "user_pageviews", ",", "user_downloads", ",", "ip_user", "=", "False", ")", ":", "views_min", "=", "self", ".", "config", ".", "get", "(", "'user_views_min'", ")", "views_max", "=", "self", "....
Filter and export the user profiles.
[ "Filter", "and", "export", "the", "user", "profiles", "." ]
train
https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/profiles.py#L67-L101
inveniosoftware-contrib/record-recommender
record_recommender/profiles.py
Profiles.create_profiles
def create_profiles(self, prefix, weeks, ip_user=False): """Create the user profiles for the given weeks.""" # Future: Add a time range in weeks for how long a user is considered # as the same user. # Count accessed records record_counter = {} for year, week in w...
python
def create_profiles(self, prefix, weeks, ip_user=False): """Create the user profiles for the given weeks.""" # Future: Add a time range in weeks for how long a user is considered # as the same user. # Count accessed records record_counter = {} for year, week in w...
[ "def", "create_profiles", "(", "self", ",", "prefix", ",", "weeks", ",", "ip_user", "=", "False", ")", ":", "# Future: Add a time range in weeks for how long a user is considered", "# as the same user.", "# Count accessed records", "record_counter", "=", "{", "}", "...
Create the user profiles for the given weeks.
[ "Create", "the", "user", "profiles", "for", "the", "given", "weeks", "." ]
train
https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/profiles.py#L103-L127
inveniosoftware-contrib/record-recommender
record_recommender/profiles.py
Profiles.count_records
def count_records(self, record_counter, file): """Count the number of viewed records.""" counter = record_counter events_counter = 0 for record in file.get_records(): recid = record[2] counter[recid] = counter.get(recid, 0) + 1 events_counter += 1 ...
python
def count_records(self, record_counter, file): """Count the number of viewed records.""" counter = record_counter events_counter = 0 for record in file.get_records(): recid = record[2] counter[recid] = counter.get(recid, 0) + 1 events_counter += 1 ...
[ "def", "count_records", "(", "self", ",", "record_counter", ",", "file", ")", ":", "counter", "=", "record_counter", "events_counter", "=", "0", "for", "record", "in", "file", ".", "get_records", "(", ")", ":", "recid", "=", "record", "[", "2", "]", "cou...
Count the number of viewed records.
[ "Count", "the", "number", "of", "viewed", "records", "." ]
train
https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/profiles.py#L129-L139
inveniosoftware-contrib/record-recommender
record_recommender/profiles.py
Profiles.filter_counter
def filter_counter(self, counter, min=2, max=100000000): """ Filter the counted records. Returns: List with record numbers. """ records_filterd = {} counter_all_records = 0 for item in counter: counter_all_records += 1 if max > counter[ite...
python
def filter_counter(self, counter, min=2, max=100000000): """ Filter the counted records. Returns: List with record numbers. """ records_filterd = {} counter_all_records = 0 for item in counter: counter_all_records += 1 if max > counter[ite...
[ "def", "filter_counter", "(", "self", ",", "counter", ",", "min", "=", "2", ",", "max", "=", "100000000", ")", ":", "records_filterd", "=", "{", "}", "counter_all_records", "=", "0", "for", "item", "in", "counter", ":", "counter_all_records", "+=", "1", ...
Filter the counted records. Returns: List with record numbers.
[ "Filter", "the", "counted", "records", "." ]
train
https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/profiles.py#L141-L156
inveniosoftware-contrib/record-recommender
record_recommender/profiles.py
Profiles._create_user_profiles
def _create_user_profiles(self, profiles, file, valid_records, ip_user=False, year=None, week=None): """ Create user profiles with all the records visited or downloaded. Returns: Dictionary with the user id and a record list. {'2323': [1, 2, 4]} """...
python
def _create_user_profiles(self, profiles, file, valid_records, ip_user=False, year=None, week=None): """ Create user profiles with all the records visited or downloaded. Returns: Dictionary with the user id and a record list. {'2323': [1, 2, 4]} """...
[ "def", "_create_user_profiles", "(", "self", ",", "profiles", ",", "file", ",", "valid_records", ",", "ip_user", "=", "False", ",", "year", "=", "None", ",", "week", "=", "None", ")", ":", "for", "record", "in", "file", ".", "get_records", "(", ")", ":...
Create user profiles with all the records visited or downloaded. Returns: Dictionary with the user id and a record list. {'2323': [1, 2, 4]}
[ "Create", "user", "profiles", "with", "all", "the", "records", "visited", "or", "downloaded", "." ]
train
https://github.com/inveniosoftware-contrib/record-recommender/blob/07f71e783369e6373218b5e6ba0bf15901e9251a/record_recommender/profiles.py#L158-L186
TechnicalBro/simple-python-plugins
simpleplugins/__init__.py
get_filename
def get_filename(file): """ Safe method to retrieve only the name of the file. :param file: Path of the file to retrieve the name from. :return: None if the file is non-existant, otherwise the filename (extension included) :rtype: None, str """ if not os.path.exists(file): return Non...
python
def get_filename(file): """ Safe method to retrieve only the name of the file. :param file: Path of the file to retrieve the name from. :return: None if the file is non-existant, otherwise the filename (extension included) :rtype: None, str """ if not os.path.exists(file): return Non...
[ "def", "get_filename", "(", "file", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "file", ")", ":", "return", "None", "return", "\"%s%s\"", "%", "os", ".", "path", ".", "splitext", "(", "file", ")" ]
Safe method to retrieve only the name of the file. :param file: Path of the file to retrieve the name from. :return: None if the file is non-existant, otherwise the filename (extension included) :rtype: None, str
[ "Safe", "method", "to", "retrieve", "only", "the", "name", "of", "the", "file", ".", ":", "param", "file", ":", "Path", "of", "the", "file", "to", "retrieve", "the", "name", "from", ".", ":", "return", ":", "None", "if", "the", "file", "is", "non", ...
train
https://github.com/TechnicalBro/simple-python-plugins/blob/971f047c85c634bcbd28f247c8214dcf77a345f9/simpleplugins/__init__.py#L39-L48
TechnicalBro/simple-python-plugins
simpleplugins/__init__.py
import_module_from_file
def import_module_from_file(full_path_to_module): """ Import a module given the full path/filename of the .py file Python 3.4 """ if inspect.ismodule(full_path_to_module): return full_path_to_module module = None try: # Get module name and path from full path modul...
python
def import_module_from_file(full_path_to_module): """ Import a module given the full path/filename of the .py file Python 3.4 """ if inspect.ismodule(full_path_to_module): return full_path_to_module module = None try: # Get module name and path from full path modul...
[ "def", "import_module_from_file", "(", "full_path_to_module", ")", ":", "if", "inspect", ".", "ismodule", "(", "full_path_to_module", ")", ":", "return", "full_path_to_module", "module", "=", "None", "try", ":", "# Get module name and path from full path", "module_dir", ...
Import a module given the full path/filename of the .py file Python 3.4
[ "Import", "a", "module", "given", "the", "full", "path", "/", "filename", "of", "the", ".", "py", "file", "Python", "3", ".", "4" ]
train
https://github.com/TechnicalBro/simple-python-plugins/blob/971f047c85c634bcbd28f247c8214dcf77a345f9/simpleplugins/__init__.py#L51-L78
TechnicalBro/simple-python-plugins
simpleplugins/__init__.py
PluginManager.register
def register(self, plugin=None, plugin_file=None, directory=None, skip_types=None, override=False, activate=True): """ Register a plugin, or plugins to be managed and recognized by the plugin manager. Will take a plugin instance, file where a plugin / plugin(s) reside, parent directory t...
python
def register(self, plugin=None, plugin_file=None, directory=None, skip_types=None, override=False, activate=True): """ Register a plugin, or plugins to be managed and recognized by the plugin manager. Will take a plugin instance, file where a plugin / plugin(s) reside, parent directory t...
[ "def", "register", "(", "self", ",", "plugin", "=", "None", ",", "plugin_file", "=", "None", ",", "directory", "=", "None", ",", "skip_types", "=", "None", ",", "override", "=", "False", ",", "activate", "=", "True", ")", ":", "# Double verify that there's...
Register a plugin, or plugins to be managed and recognized by the plugin manager. Will take a plugin instance, file where a plugin / plugin(s) reside, parent directory that holds plugin(s), or sub-folders with plugin(s). Will optionally "activate" the plugins, and perform any operations defined...
[ "Register", "a", "plugin", "or", "plugins", "to", "be", "managed", "and", "recognized", "by", "the", "plugin", "manager", ".", "Will", "take", "a", "plugin", "instance", "file", "where", "a", "plugin", "/", "plugin", "(", "s", ")", "reside", "parent", "d...
train
https://github.com/TechnicalBro/simple-python-plugins/blob/971f047c85c634bcbd28f247c8214dcf77a345f9/simpleplugins/__init__.py#L129-L251
TechnicalBro/simple-python-plugins
simpleplugins/__init__.py
PluginManager.unregister
def unregister(self, plugin=None, plugin_file=None): """ Unregister all plugins, or a specific plugin, via an instance, or file (path) containing plugin(s). When this method is called without any arguments then all plugins will be deactivated. :param plugin: Plugin to unregister. ...
python
def unregister(self, plugin=None, plugin_file=None): """ Unregister all plugins, or a specific plugin, via an instance, or file (path) containing plugin(s). When this method is called without any arguments then all plugins will be deactivated. :param plugin: Plugin to unregister. ...
[ "def", "unregister", "(", "self", ",", "plugin", "=", "None", ",", "plugin_file", "=", "None", ")", ":", "if", "plugin", "is", "None", "and", "plugin_file", "is", "None", ":", "for", "name", ",", "plugin", "in", "self", ".", "plugins", ".", "items", ...
Unregister all plugins, or a specific plugin, via an instance, or file (path) containing plugin(s). When this method is called without any arguments then all plugins will be deactivated. :param plugin: Plugin to unregister. :param plugin_file: File containing plugin(s) to unregister. :re...
[ "Unregister", "all", "plugins", "or", "a", "specific", "plugin", "via", "an", "instance", "or", "file", "(", "path", ")", "containing", "plugin", "(", "s", ")", ".", "When", "this", "method", "is", "called", "without", "any", "arguments", "then", "all", ...
train
https://github.com/TechnicalBro/simple-python-plugins/blob/971f047c85c634bcbd28f247c8214dcf77a345f9/simpleplugins/__init__.py#L287-L317
TechnicalBro/simple-python-plugins
simpleplugins/__init__.py
PluginManager.get_plugins
def get_plugins(self, plugin_type=None): """ Retrieve a list of plugins in the PluginManager. All plugins if no arguments are provides, or of the specified type. :param plugin_type: list: Types of plugins to retrieve from the plugin manager. :return: Plugins being managed by the ...
python
def get_plugins(self, plugin_type=None): """ Retrieve a list of plugins in the PluginManager. All plugins if no arguments are provides, or of the specified type. :param plugin_type: list: Types of plugins to retrieve from the plugin manager. :return: Plugins being managed by the ...
[ "def", "get_plugins", "(", "self", ",", "plugin_type", "=", "None", ")", ":", "if", "plugin_type", "is", "None", ":", "return", "self", ".", "plugins", ".", "values", "(", ")", "plugin_list", "=", "[", "]", "for", "name", ",", "plugin", "in", "self", ...
Retrieve a list of plugins in the PluginManager. All plugins if no arguments are provides, or of the specified type. :param plugin_type: list: Types of plugins to retrieve from the plugin manager. :return: Plugins being managed by the Manager (optionally of the desired plugin_type). :rty...
[ "Retrieve", "a", "list", "of", "plugins", "in", "the", "PluginManager", ".", "All", "plugins", "if", "no", "arguments", "are", "provides", "or", "of", "the", "specified", "type", ".", ":", "param", "plugin_type", ":", "list", ":", "Types", "of", "plugins",...
train
https://github.com/TechnicalBro/simple-python-plugins/blob/971f047c85c634bcbd28f247c8214dcf77a345f9/simpleplugins/__init__.py#L319-L335
TechnicalBro/simple-python-plugins
simpleplugins/__init__.py
PluginManager.has_plugin
def has_plugin(self, name=None, plugin_type=None): """ Check if the manager has a plugin / plugin(s), either by its name, type, or simply checking if the manager has any plugins registered in it. Utilizing the name argument will check if a plugin with that name exists in the manager. ...
python
def has_plugin(self, name=None, plugin_type=None): """ Check if the manager has a plugin / plugin(s), either by its name, type, or simply checking if the manager has any plugins registered in it. Utilizing the name argument will check if a plugin with that name exists in the manager. ...
[ "def", "has_plugin", "(", "self", ",", "name", "=", "None", ",", "plugin_type", "=", "None", ")", ":", "# If there's no arguments passed to this, then we check if there's simply any plugins", "# Registered in the plugin manager.", "if", "name", "is", "None", "and", "plugin_...
Check if the manager has a plugin / plugin(s), either by its name, type, or simply checking if the manager has any plugins registered in it. Utilizing the name argument will check if a plugin with that name exists in the manager. Using both the name and plugin_type arguments will check if a plu...
[ "Check", "if", "the", "manager", "has", "a", "plugin", "/", "plugin", "(", "s", ")", "either", "by", "its", "name", "type", "or", "simply", "checking", "if", "the", "manager", "has", "any", "plugins", "registered", "in", "it", "." ]
train
https://github.com/TechnicalBro/simple-python-plugins/blob/971f047c85c634bcbd28f247c8214dcf77a345f9/simpleplugins/__init__.py#L349-L383
TechnicalBro/simple-python-plugins
simpleplugins/__init__.py
PluginManager.scan_for_plugins
def scan_for_plugins(directory): """ Scan a directory for modules that contains plugin(s). :param directory: Path of the folder/directory to scan. :return: Dictionary of file (key) and plugins (value), where the key is the path of the module and value is a list of plugins inside that mod...
python
def scan_for_plugins(directory): """ Scan a directory for modules that contains plugin(s). :param directory: Path of the folder/directory to scan. :return: Dictionary of file (key) and plugins (value), where the key is the path of the module and value is a list of plugins inside that mod...
[ "def", "scan_for_plugins", "(", "directory", ")", ":", "if", "not", "os", ".", "path", ".", "exists", "(", "os", ".", "path", ".", "expanduser", "(", "directory", ")", ")", ":", "raise", "FileNotFoundError", "(", "\"Unable to locate directory %s\"", "%", "di...
Scan a directory for modules that contains plugin(s). :param directory: Path of the folder/directory to scan. :return: Dictionary of file (key) and plugins (value), where the key is the path of the module and value is a list of plugins inside that module. :rtype: dict
[ "Scan", "a", "directory", "for", "modules", "that", "contains", "plugin", "(", "s", ")", ".", ":", "param", "directory", ":", "Path", "of", "the", "folder", "/", "directory", "to", "scan", ".", ":", "return", ":", "Dictionary", "of", "file", "(", "key"...
train
https://github.com/TechnicalBro/simple-python-plugins/blob/971f047c85c634bcbd28f247c8214dcf77a345f9/simpleplugins/__init__.py#L393-L413
TechnicalBro/simple-python-plugins
simpleplugins/__init__.py
PluginManager.get_plugins_in_module
def get_plugins_in_module(module_path, suppress=False): """ Inspect a module, via its path, and retrieve a list of the plugins inside the module. :param module_path: Path of the module to inspect. :param suppress: Whether or not to suppresss exceptions. :raises: PluginException ...
python
def get_plugins_in_module(module_path, suppress=False): """ Inspect a module, via its path, and retrieve a list of the plugins inside the module. :param module_path: Path of the module to inspect. :param suppress: Whether or not to suppresss exceptions. :raises: PluginException ...
[ "def", "get_plugins_in_module", "(", "module_path", ",", "suppress", "=", "False", ")", ":", "module", "=", "module_path", "if", "inspect", ".", "ismodule", "(", "module_path", ")", "else", "import_module_from_file", "(", "module_path", ")", "if", "module", "is"...
Inspect a module, via its path, and retrieve a list of the plugins inside the module. :param module_path: Path of the module to inspect. :param suppress: Whether or not to suppresss exceptions. :raises: PluginException :return: A list of all the plugins inside the specified module. ...
[ "Inspect", "a", "module", "via", "its", "path", "and", "retrieve", "a", "list", "of", "the", "plugins", "inside", "the", "module", ".", ":", "param", "module_path", ":", "Path", "of", "the", "module", "to", "inspect", ".", ":", "param", "suppress", ":", ...
train
https://github.com/TechnicalBro/simple-python-plugins/blob/971f047c85c634bcbd28f247c8214dcf77a345f9/simpleplugins/__init__.py#L416-L439
noobermin/lspreader
bin/nearest.py
handle_dims
def handle_dims(opts): ''' Script option handling. ''' use,res = [],[]; if opts['--X']: use.append('x'); res.append(int(opts['--xres'])); if opts['--Y']: use.append('y'); res.append(int(opts['--yres'])); if opts['--Z']: use.append('z'); res.app...
python
def handle_dims(opts): ''' Script option handling. ''' use,res = [],[]; if opts['--X']: use.append('x'); res.append(int(opts['--xres'])); if opts['--Y']: use.append('y'); res.append(int(opts['--yres'])); if opts['--Z']: use.append('z'); res.app...
[ "def", "handle_dims", "(", "opts", ")", ":", "use", ",", "res", "=", "[", "]", ",", "[", "]", "if", "opts", "[", "'--X'", "]", ":", "use", ".", "append", "(", "'x'", ")", "res", ".", "append", "(", "int", "(", "opts", "[", "'--xres'", "]", ")...
Script option handling.
[ "Script", "option", "handling", "." ]
train
https://github.com/noobermin/lspreader/blob/903b9d6427513b07986ffacf76cbca54e18d8be6/bin/nearest.py#L40-L67
jpscaletti/moar
moar/optimage.py
_temporary_filenames
def _temporary_filenames(total): """Context manager to create temporary files and remove them after use.""" temp_files = [_get_temporary_filename('optimage-') for i in range(total)] yield temp_files for temp_file in temp_files: try: os.remove(temp_file) except OSError: ...
python
def _temporary_filenames(total): """Context manager to create temporary files and remove them after use.""" temp_files = [_get_temporary_filename('optimage-') for i in range(total)] yield temp_files for temp_file in temp_files: try: os.remove(temp_file) except OSError: ...
[ "def", "_temporary_filenames", "(", "total", ")", ":", "temp_files", "=", "[", "_get_temporary_filename", "(", "'optimage-'", ")", "for", "i", "in", "range", "(", "total", ")", "]", "yield", "temp_files", "for", "temp_file", "in", "temp_files", ":", "try", "...
Context manager to create temporary files and remove them after use.
[ "Context", "manager", "to", "create", "temporary", "files", "and", "remove", "them", "after", "use", "." ]
train
https://github.com/jpscaletti/moar/blob/22694e5671b6adaccc4c9c87db7bdd701d20e734/moar/optimage.py#L67-L77
jpscaletti/moar
moar/optimage.py
_process
def _process(compressor, input_filename, output_filename): """Helper function to compress an image. Returns: _CompressorResult named tuple, with the resulting size, the name of the output file and the name of the compressor. """ compressor(input_filename, output_filename) result_size = ...
python
def _process(compressor, input_filename, output_filename): """Helper function to compress an image. Returns: _CompressorResult named tuple, with the resulting size, the name of the output file and the name of the compressor. """ compressor(input_filename, output_filename) result_size = ...
[ "def", "_process", "(", "compressor", ",", "input_filename", ",", "output_filename", ")", ":", "compressor", "(", "input_filename", ",", "output_filename", ")", "result_size", "=", "os", ".", "path", ".", "getsize", "(", "output_filename", ")", "return", "_Compr...
Helper function to compress an image. Returns: _CompressorResult named tuple, with the resulting size, the name of the output file and the name of the compressor.
[ "Helper", "function", "to", "compress", "an", "image", "." ]
train
https://github.com/jpscaletti/moar/blob/22694e5671b6adaccc4c9c87db7bdd701d20e734/moar/optimage.py#L127-L137
jpscaletti/moar
moar/optimage.py
_compress_with
def _compress_with(input_filename, output_filename, compressors): """Helper function to compress an image with several compressors. In case the compressors do not improve the filesize or in case the resulting image is not equivalent to the source, then the output will be a copy of the input. """ ...
python
def _compress_with(input_filename, output_filename, compressors): """Helper function to compress an image with several compressors. In case the compressors do not improve the filesize or in case the resulting image is not equivalent to the source, then the output will be a copy of the input. """ ...
[ "def", "_compress_with", "(", "input_filename", ",", "output_filename", ",", "compressors", ")", ":", "with", "_temporary_filenames", "(", "len", "(", "compressors", ")", ")", "as", "temp_filenames", ":", "results", "=", "[", "]", "for", "compressor", ",", "te...
Helper function to compress an image with several compressors. In case the compressors do not improve the filesize or in case the resulting image is not equivalent to the source, then the output will be a copy of the input.
[ "Helper", "function", "to", "compress", "an", "image", "with", "several", "compressors", "." ]
train
https://github.com/jpscaletti/moar/blob/22694e5671b6adaccc4c9c87db7bdd701d20e734/moar/optimage.py#L140-L168
wtsi-hgi/gitlab-build-variables
gitlabbuildvariables/update/_builders.py
ProjectVariablesUpdaterBuilder.build
def build(self, project: str, groups: Iterable[str], gitlab_config: GitLabConfig) \ -> ProjectVariablesUpdaterType: """ Builds a `ProjectVariablesUpdater` instance using the given arguments. :param project: the project that variables are to be updated for :param groups: the g...
python
def build(self, project: str, groups: Iterable[str], gitlab_config: GitLabConfig) \ -> ProjectVariablesUpdaterType: """ Builds a `ProjectVariablesUpdater` instance using the given arguments. :param project: the project that variables are to be updated for :param groups: the g...
[ "def", "build", "(", "self", ",", "project", ":", "str", ",", "groups", ":", "Iterable", "[", "str", "]", ",", "gitlab_config", ":", "GitLabConfig", ")", "->", "ProjectVariablesUpdaterType", ":" ]
Builds a `ProjectVariablesUpdater` instance using the given arguments. :param project: the project that variables are to be updated for :param groups: the groups of settings that should be set for the project :param gitlab_config: the configuration required to access GitLab :return: the ...
[ "Builds", "a", "ProjectVariablesUpdater", "instance", "using", "the", "given", "arguments", ".", ":", "param", "project", ":", "the", "project", "that", "variables", "are", "to", "be", "updated", "for", ":", "param", "groups", ":", "the", "groups", "of", "se...
train
https://github.com/wtsi-hgi/gitlab-build-variables/blob/ed1afe50bc41fa20ffb29cacba5ff6dbc2446808/gitlabbuildvariables/update/_builders.py#L16-L24
jcalogovic/lightning
stormstats/storm.py
Storm.get_map
def get_map(self, create_html=True): """Strike data should be a pd.DF from the WWLN data files read by read_WWLN()""" strike_data = self.df num_rows = len(self.df) if num_rows > 1000: print("Warning, you have requested lots of data be mapped." / " Li...
python
def get_map(self, create_html=True): """Strike data should be a pd.DF from the WWLN data files read by read_WWLN()""" strike_data = self.df num_rows = len(self.df) if num_rows > 1000: print("Warning, you have requested lots of data be mapped." / " Li...
[ "def", "get_map", "(", "self", ",", "create_html", "=", "True", ")", ":", "strike_data", "=", "self", ".", "df", "num_rows", "=", "len", "(", "self", ".", "df", ")", "if", "num_rows", ">", "1000", ":", "print", "(", "\"Warning, you have requested lots of d...
Strike data should be a pd.DF from the WWLN data files read by read_WWLN()
[ "Strike", "data", "should", "be", "a", "pd", ".", "DF", "from", "the", "WWLN", "data", "files", "read", "by", "read_WWLN", "()" ]
train
https://github.com/jcalogovic/lightning/blob/f9e52731c9dd40cb302295ec36a444e0377d0570/stormstats/storm.py#L19-L41
jcalogovic/lightning
stormstats/storm.py
Storm.read_blitzorg_csv
def read_blitzorg_csv(f=None): """ Function to read csv data downloaded from Blitzorgs historical data section. Time is in POSIX timestamps (x1000000000). An eg is kept in stormstats/egdata/archive_2_raw.txt. If no data file is specified the function will assume you want to read ...
python
def read_blitzorg_csv(f=None): """ Function to read csv data downloaded from Blitzorgs historical data section. Time is in POSIX timestamps (x1000000000). An eg is kept in stormstats/egdata/archive_2_raw.txt. If no data file is specified the function will assume you want to read ...
[ "def", "read_blitzorg_csv", "(", "f", "=", "None", ")", ":", "factor", "=", "1000000000", "# don't change this magic number! Its from Bzorg.", "if", "f", ":", "tmp", "=", "pd", ".", "read_csv", "(", "f", ")", "else", ":", "f", "=", "pkg", ".", "resource_file...
Function to read csv data downloaded from Blitzorgs historical data section. Time is in POSIX timestamps (x1000000000). An eg is kept in stormstats/egdata/archive_2_raw.txt. If no data file is specified the function will assume you want to read this example data. Geopandas dataframe will...
[ "Function", "to", "read", "csv", "data", "downloaded", "from", "Blitzorgs", "historical", "data", "section", ".", "Time", "is", "in", "POSIX", "timestamps", "(", "x1000000000", ")", ".", "An", "eg", "is", "kept", "in", "stormstats", "/", "egdata", "/", "ar...
train
https://github.com/jcalogovic/lightning/blob/f9e52731c9dd40cb302295ec36a444e0377d0570/stormstats/storm.py#L44-L69
jcalogovic/lightning
stormstats/storm.py
Storm.add_to_map
def add_to_map(map_obj, lat, lon, date_time, key, cluster_obj): """Add individual elements to a foilum map in a cluster object""" text = "Event {0} at {1}".format(key, date_time.split()[1]) folium.Marker([lat, lon], popup=text).add_to(cluster_obj)
python
def add_to_map(map_obj, lat, lon, date_time, key, cluster_obj): """Add individual elements to a foilum map in a cluster object""" text = "Event {0} at {1}".format(key, date_time.split()[1]) folium.Marker([lat, lon], popup=text).add_to(cluster_obj)
[ "def", "add_to_map", "(", "map_obj", ",", "lat", ",", "lon", ",", "date_time", ",", "key", ",", "cluster_obj", ")", ":", "text", "=", "\"Event {0} at {1}\"", ".", "format", "(", "key", ",", "date_time", ".", "split", "(", ")", "[", "1", "]", ")", "fo...
Add individual elements to a foilum map in a cluster object
[ "Add", "individual", "elements", "to", "a", "foilum", "map", "in", "a", "cluster", "object" ]
train
https://github.com/jcalogovic/lightning/blob/f9e52731c9dd40cb302295ec36a444e0377d0570/stormstats/storm.py#L72-L75
MagicGreenDragon/winvers
winvers/winver.py
get_version
def get_version(): """ Get the Windows OS version running on the machine. Params: None Returns: The Windows OS version running on the machine (comparables with the values list in the class). """ # Other OS check if not 'win' in sys.platform: return N...
python
def get_version(): """ Get the Windows OS version running on the machine. Params: None Returns: The Windows OS version running on the machine (comparables with the values list in the class). """ # Other OS check if not 'win' in sys.platform: return N...
[ "def", "get_version", "(", ")", ":", "# Other OS check\r", "if", "not", "'win'", "in", "sys", ".", "platform", ":", "return", "NO_WIN", "# Get infos\r", "win_ver", "=", "sys", ".", "getwindowsversion", "(", ")", "try", ":", "# Python 3.6.x or upper -> Use 'platfor...
Get the Windows OS version running on the machine. Params: None Returns: The Windows OS version running on the machine (comparables with the values list in the class).
[ "Get", "the", "Windows", "OS", "version", "running", "on", "the", "machine", ".", "Params", ":", "None", "Returns", ":", "The", "Windows", "OS", "version", "running", "on", "the", "machine", "(", "comparables", "with", "the", "values", "list", "in", "the",...
train
https://github.com/MagicGreenDragon/winvers/blob/4f4bcf56234d7021344b5a4384ecb4bcbb14094e/winvers/winver.py#L23-L69
maxweisspoker/simplebitcoinfuncs
simplebitcoinfuncs/signandverify.py
sign
def sign(hash,priv,k=0): ''' Returns a DER-encoded signature from a input of a hash and private key, and optionally a K value. Hash and private key inputs must be 64-char hex strings, k input is an int/long. >>> h = 'f7011e94125b5bba7f62eb25efe23339eb1637539206c87df3ee61b5ec6b023e' >>> p =...
python
def sign(hash,priv,k=0): ''' Returns a DER-encoded signature from a input of a hash and private key, and optionally a K value. Hash and private key inputs must be 64-char hex strings, k input is an int/long. >>> h = 'f7011e94125b5bba7f62eb25efe23339eb1637539206c87df3ee61b5ec6b023e' >>> p =...
[ "def", "sign", "(", "hash", ",", "priv", ",", "k", "=", "0", ")", ":", "if", "k", "==", "0", ":", "k", "=", "generate_k", "(", "priv", ",", "hash", ")", "hash", "=", "int", "(", "hash", ",", "16", ")", "priv", "=", "int", "(", "priv", ",", ...
Returns a DER-encoded signature from a input of a hash and private key, and optionally a K value. Hash and private key inputs must be 64-char hex strings, k input is an int/long. >>> h = 'f7011e94125b5bba7f62eb25efe23339eb1637539206c87df3ee61b5ec6b023e' >>> p = 'c05694a7af0e01dceb63e5912a415c28d3f...
[ "Returns", "a", "DER", "-", "encoded", "signature", "from", "a", "input", "of", "a", "hash", "and", "private", "key", "and", "optionally", "a", "K", "value", "." ]
train
https://github.com/maxweisspoker/simplebitcoinfuncs/blob/ad332433dfcc067e86d2e77fa0c8f1a27daffb63/simplebitcoinfuncs/signandverify.py#L36-L66
maxweisspoker/simplebitcoinfuncs
simplebitcoinfuncs/signandverify.py
verify
def verify(hash,sig,pub,exceptonhighS=False): ''' Verify a DER-encoded signature against a given hash and public key No checking of format is done in this function, so the signature format (and other inputs) should be verified as being the correct format prior to using this method. Hash is jus...
python
def verify(hash,sig,pub,exceptonhighS=False): ''' Verify a DER-encoded signature against a given hash and public key No checking of format is done in this function, so the signature format (and other inputs) should be verified as being the correct format prior to using this method. Hash is jus...
[ "def", "verify", "(", "hash", ",", "sig", ",", "pub", ",", "exceptonhighS", "=", "False", ")", ":", "rlen", "=", "2", "*", "int", "(", "sig", "[", "6", ":", "8", "]", ",", "16", ")", "r", "=", "int", "(", "sig", "[", "8", ":", "8", "+", "...
Verify a DER-encoded signature against a given hash and public key No checking of format is done in this function, so the signature format (and other inputs) should be verified as being the correct format prior to using this method. Hash is just 64-char hex string Public key format can be verified...
[ "Verify", "a", "DER", "-", "encoded", "signature", "against", "a", "given", "hash", "and", "public", "key" ]
train
https://github.com/maxweisspoker/simplebitcoinfuncs/blob/ad332433dfcc067e86d2e77fa0c8f1a27daffb63/simplebitcoinfuncs/signandverify.py#L68-L119
maxweisspoker/simplebitcoinfuncs
simplebitcoinfuncs/signandverify.py
checksigformat
def checksigformat(a,invalidatehighS=False): ''' Checks input to see if it's a correctly formatted DER Bitcoin signature in hex string format. Returns True/False. If it excepts, there's a different problem unrelated to the signature... This does NOT valid the signature in any way, it ONLY che...
python
def checksigformat(a,invalidatehighS=False): ''' Checks input to see if it's a correctly formatted DER Bitcoin signature in hex string format. Returns True/False. If it excepts, there's a different problem unrelated to the signature... This does NOT valid the signature in any way, it ONLY che...
[ "def", "checksigformat", "(", "a", ",", "invalidatehighS", "=", "False", ")", ":", "try", ":", "a", "=", "hexstrlify", "(", "unhexlify", "(", "a", ")", ")", "except", ":", "return", "False", "try", ":", "rlen", "=", "2", "*", "int", "(", "a", "[", ...
Checks input to see if it's a correctly formatted DER Bitcoin signature in hex string format. Returns True/False. If it excepts, there's a different problem unrelated to the signature... This does NOT valid the signature in any way, it ONLY checks that it is formatted properly. If invalidate...
[ "Checks", "input", "to", "see", "if", "it", "s", "a", "correctly", "formatted", "DER", "Bitcoin", "signature", "in", "hex", "string", "format", "." ]
train
https://github.com/maxweisspoker/simplebitcoinfuncs/blob/ad332433dfcc067e86d2e77fa0c8f1a27daffb63/simplebitcoinfuncs/signandverify.py#L122-L182
maxweisspoker/simplebitcoinfuncs
simplebitcoinfuncs/signandverify.py
signmsg
def signmsg(msg,priv,iscompressed,k=0): ''' Sign a message -- the message itself, not a hash -- with a given private key. Input private key must be hex, NOT WIF. Use wiftohex() found in .bitcoin in order to get the hex private key and whether it is (or rather, its public key is) compressed. ...
python
def signmsg(msg,priv,iscompressed,k=0): ''' Sign a message -- the message itself, not a hash -- with a given private key. Input private key must be hex, NOT WIF. Use wiftohex() found in .bitcoin in order to get the hex private key and whether it is (or rather, its public key is) compressed. ...
[ "def", "signmsg", "(", "msg", ",", "priv", ",", "iscompressed", ",", "k", "=", "0", ")", ":", "omsg", "=", "msg", "# Stripping carraige returns is standard practice in every", "# implementation I found, including Bitcoin Core", "msg", "=", "msg", ".", "replace", "(", ...
Sign a message -- the message itself, not a hash -- with a given private key. Input private key must be hex, NOT WIF. Use wiftohex() found in .bitcoin in order to get the hex private key and whether it is (or rather, its public key is) compressed. 'iscompressed' is True/False bool for whether or ...
[ "Sign", "a", "message", "--", "the", "message", "itself", "not", "a", "hash", "--", "with", "a", "given", "private", "key", "." ]
train
https://github.com/maxweisspoker/simplebitcoinfuncs/blob/ad332433dfcc067e86d2e77fa0c8f1a27daffb63/simplebitcoinfuncs/signandverify.py#L185-L266
maxweisspoker/simplebitcoinfuncs
simplebitcoinfuncs/signandverify.py
verifymsg
def verifymsg(msg,sig): ''' Compares the message and input signature, and outputs what the corresponding public key is that would make that message/signature pair valid. I didn't set it to take in a pubkey and output True/False because sometimes it is useful to have the resulting key, even if t...
python
def verifymsg(msg,sig): ''' Compares the message and input signature, and outputs what the corresponding public key is that would make that message/signature pair valid. I didn't set it to take in a pubkey and output True/False because sometimes it is useful to have the resulting key, even if t...
[ "def", "verifymsg", "(", "msg", ",", "sig", ")", ":", "msg", "=", "msg", ".", "replace", "(", "\"\\r\\n\"", ",", "\"\\n\"", ")", "# Again, standard convention to remove returns", "msg1", "=", "hexstrlify", "(", "bytearray", "(", "\"\\x18Bitcoin Signed Message:\\n\""...
Compares the message and input signature, and outputs what the corresponding public key is that would make that message/signature pair valid. I didn't set it to take in a pubkey and output True/False because sometimes it is useful to have the resulting key, even if the msg/sig pair is invalid. ...
[ "Compares", "the", "message", "and", "input", "signature", "and", "outputs", "what", "the", "corresponding", "public", "key", "is", "that", "would", "make", "that", "message", "/", "signature", "pair", "valid", "." ]
train
https://github.com/maxweisspoker/simplebitcoinfuncs/blob/ad332433dfcc067e86d2e77fa0c8f1a27daffb63/simplebitcoinfuncs/signandverify.py#L269-L334
ravenac95/pippy
pippy/req.py
PippyRequirementSet.prepare_files
def prepare_files(self, finder, force_root_egg_info=False, bundle=False): """Prepare process. Create temp directories, download and/or unpack files.""" unnamed = list(self.unnamed_requirements) reqs = list(self.requirements.values()) while reqs or unnamed: if unnamed: ...
python
def prepare_files(self, finder, force_root_egg_info=False, bundle=False): """Prepare process. Create temp directories, download and/or unpack files.""" unnamed = list(self.unnamed_requirements) reqs = list(self.requirements.values()) while reqs or unnamed: if unnamed: ...
[ "def", "prepare_files", "(", "self", ",", "finder", ",", "force_root_egg_info", "=", "False", ",", "bundle", "=", "False", ")", ":", "unnamed", "=", "list", "(", "self", ".", "unnamed_requirements", ")", "reqs", "=", "list", "(", "self", ".", "requirements...
Prepare process. Create temp directories, download and/or unpack files.
[ "Prepare", "process", ".", "Create", "temp", "directories", "download", "and", "/", "or", "unpack", "files", "." ]
train
https://github.com/ravenac95/pippy/blob/8ae26e0a3f20d99103a421d9b94dc8d2169688b1/pippy/req.py#L95-L251
GMadorell/abris
abris_transform/dataframe_manipulation/split_dataframe.py
split_dataframe
def split_dataframe(df, train_percentage=0.6, cv_percentage=0.2, test_percentage=0.2): """ @return training, cv, test (as pandas dataframes) @param df: pandas dataframe @param train_percentage: float | percentage of data for training set (default=0.6) @param cv_percentage: float | pe...
python
def split_dataframe(df, train_percentage=0.6, cv_percentage=0.2, test_percentage=0.2): """ @return training, cv, test (as pandas dataframes) @param df: pandas dataframe @param train_percentage: float | percentage of data for training set (default=0.6) @param cv_percentage: float | pe...
[ "def", "split_dataframe", "(", "df", ",", "train_percentage", "=", "0.6", ",", "cv_percentage", "=", "0.2", ",", "test_percentage", "=", "0.2", ")", ":", "assert", "train_percentage", "+", "cv_percentage", "+", "test_percentage", "==", "1.0", "N", "=", "len", ...
@return training, cv, test (as pandas dataframes) @param df: pandas dataframe @param train_percentage: float | percentage of data for training set (default=0.6) @param cv_percentage: float | percentage of data for cross validation set (default=0.2) @param test_percentage: float | percen...
[ "@return", "training", "cv", "test", "(", "as", "pandas", "dataframes", ")" ]
train
https://github.com/GMadorell/abris/blob/0d8ab7ec506835a45fae6935d129f5d7e6937bb2/abris_transform/dataframe_manipulation/split_dataframe.py#L13-L41
shi-cong/PYSTUDY
PYSTUDY/office/pdflib.py
create_watermark
def create_watermark(f_jpg, pdf_out): """创建图片水印pdf """ f_pdf = pdf_out w_pdf = 20 * cm h_pdf = 20 * cm c = canvas.Canvas(f_pdf, pagesize=(w_pdf, h_pdf)) c.setFillAlpha(0.5) # 设置透明度 c.drawImage(f_jpg, 5 * cm, 5 * cm, 5 * cm, 5 * cm)
python
def create_watermark(f_jpg, pdf_out): """创建图片水印pdf """ f_pdf = pdf_out w_pdf = 20 * cm h_pdf = 20 * cm c = canvas.Canvas(f_pdf, pagesize=(w_pdf, h_pdf)) c.setFillAlpha(0.5) # 设置透明度 c.drawImage(f_jpg, 5 * cm, 5 * cm, 5 * cm, 5 * cm)
[ "def", "create_watermark", "(", "f_jpg", ",", "pdf_out", ")", ":", "f_pdf", "=", "pdf_out", "w_pdf", "=", "20", "*", "cm", "h_pdf", "=", "20", "*", "cm", "c", "=", "canvas", ".", "Canvas", "(", "f_pdf", ",", "pagesize", "=", "(", "w_pdf", ",", "h_p...
创建图片水印pdf
[ "创建图片水印pdf" ]
train
https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/office/pdflib.py#L11-L20
shi-cong/PYSTUDY
PYSTUDY/office/pdflib.py
add_watermark
def add_watermark(pdf_file_in, pdf_file_mark, pdf_file_out): """添加水印 """ pdf_output = PdfFileWriter() input_stream = open(pdf_file_in, 'rb') pdf_input = PdfFileReader(input_stream) # PDF文件被加密了 if pdf_input.getIsEncrypted(): print('该PDF文件被加密了.') # 尝试用空密码解密 try: ...
python
def add_watermark(pdf_file_in, pdf_file_mark, pdf_file_out): """添加水印 """ pdf_output = PdfFileWriter() input_stream = open(pdf_file_in, 'rb') pdf_input = PdfFileReader(input_stream) # PDF文件被加密了 if pdf_input.getIsEncrypted(): print('该PDF文件被加密了.') # 尝试用空密码解密 try: ...
[ "def", "add_watermark", "(", "pdf_file_in", ",", "pdf_file_mark", ",", "pdf_file_out", ")", ":", "pdf_output", "=", "PdfFileWriter", "(", ")", "input_stream", "=", "open", "(", "pdf_file_in", ",", "'rb'", ")", "pdf_input", "=", "PdfFileReader", "(", "input_strea...
添加水印
[ "添加水印" ]
train
https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/office/pdflib.py#L23-L56
shi-cong/PYSTUDY
PYSTUDY/office/pdflib.py
compress
def compress(pdf_in, pdf_output): """ mac下安装 brew install ghostscript :param pdf_in: :param pdf_output: :return: """ cmd = 'gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -sOutputFile=%s %s' cmd = cmd % (pdf_output, pdf_in) os.system(cmd)
python
def compress(pdf_in, pdf_output): """ mac下安装 brew install ghostscript :param pdf_in: :param pdf_output: :return: """ cmd = 'gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -sOutputFile=%s %s' cmd = cmd % (pdf_output, pdf_in) os.system(cmd)
[ "def", "compress", "(", "pdf_in", ",", "pdf_output", ")", ":", "cmd", "=", "'gs -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/screen -sOutputFile=%s %s'", "cmd", "=", "cmd", "%", "(", "pdf_output", ",", "pdf_in", ")", "os", ".", "system", "...
mac下安装 brew install ghostscript :param pdf_in: :param pdf_output: :return:
[ "mac下安装", "brew", "install", "ghostscript", ":", "param", "pdf_in", ":", ":", "param", "pdf_output", ":", ":", "return", ":" ]
train
https://github.com/shi-cong/PYSTUDY/blob/c8da7128ea18ecaa5849f2066d321e70d6f97f70/PYSTUDY/office/pdflib.py#L59-L68
briancappello/flask-sqlalchemy-bundle
flask_sqlalchemy_bundle/decorators.py
param_converter
def param_converter(*decorator_args, **decorator_kwargs): """ Call with the url parameter names as keyword argument keys, their values being the model to convert to. Models will be looked up by the url param names. If a url param name is prefixed with the snake-cased model name, the prefix will be ...
python
def param_converter(*decorator_args, **decorator_kwargs): """ Call with the url parameter names as keyword argument keys, their values being the model to convert to. Models will be looked up by the url param names. If a url param name is prefixed with the snake-cased model name, the prefix will be ...
[ "def", "param_converter", "(", "*", "decorator_args", ",", "*", "*", "decorator_kwargs", ")", ":", "def", "wrapped", "(", "fn", ")", ":", "@", "wraps", "(", "fn", ")", "def", "decorated", "(", "*", "view_args", ",", "*", "*", "view_kwargs", ")", ":", ...
Call with the url parameter names as keyword argument keys, their values being the model to convert to. Models will be looked up by the url param names. If a url param name is prefixed with the snake-cased model name, the prefix will be stripped. If a model isn't found, abort with a 404. The acti...
[ "Call", "with", "the", "url", "parameter", "names", "as", "keyword", "argument", "keys", "their", "values", "being", "the", "model", "to", "convert", "to", "." ]
train
https://github.com/briancappello/flask-sqlalchemy-bundle/blob/8150896787907ef0001839b5a6ef303edccb9b6c/flask_sqlalchemy_bundle/decorators.py#L12-L60
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/manage.py
load
def load(name, filepath, separator="---"): """Load given file into knowledge base. Simply load data into an existing knowledge base: .. code-block:: console $ inveniomanage knowledge load mykb /path/to/file.kb The file is expected to have a mapping with values: ``foo<seperator>bar`` (per...
python
def load(name, filepath, separator="---"): """Load given file into knowledge base. Simply load data into an existing knowledge base: .. code-block:: console $ inveniomanage knowledge load mykb /path/to/file.kb The file is expected to have a mapping with values: ``foo<seperator>bar`` (per...
[ "def", "load", "(", "name", ",", "filepath", ",", "separator", "=", "\"---\"", ")", ":", "current_app", ".", "logger", ".", "info", "(", "\">>> Going to load knowledge base {0} into '{1}'...\"", ".", "format", "(", "filepath", ",", "name", ")", ")", "if", "not...
Load given file into knowledge base. Simply load data into an existing knowledge base: .. code-block:: console $ inveniomanage knowledge load mykb /path/to/file.kb The file is expected to have a mapping with values: ``foo<seperator>bar`` (per line). ``<separator>`` is by default set to ...
[ "Load", "given", "file", "into", "knowledge", "base", "." ]
train
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/manage.py#L44-L83