repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py | CTOC.frombinary | def frombinary(self, s):
"""Decode the binary string into an in memory list.
S is a binary string."""
entrylen = struct.calcsize(self.ENTRYSTRUCT)
p = 0
while p<len(s):
(slen, dpos, dlen, ulen, flag, typcd) = struct.unpack(self.ENTRYSTRUCT,
... | python | def frombinary(self, s):
"""Decode the binary string into an in memory list.
S is a binary string."""
entrylen = struct.calcsize(self.ENTRYSTRUCT)
p = 0
while p<len(s):
(slen, dpos, dlen, ulen, flag, typcd) = struct.unpack(self.ENTRYSTRUCT,
... | [
"def",
"frombinary",
"(",
"self",
",",
"s",
")",
":",
"entrylen",
"=",
"struct",
".",
"calcsize",
"(",
"self",
".",
"ENTRYSTRUCT",
")",
"p",
"=",
"0",
"while",
"p",
"<",
"len",
"(",
"s",
")",
":",
"(",
"slen",
",",
"dpos",
",",
"dlen",
",",
"ul... | Decode the binary string into an in memory list.
S is a binary string. | [
"Decode",
"the",
"binary",
"string",
"into",
"an",
"in",
"memory",
"list",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py#L35-L56 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py | CTOC.tobinary | def tobinary(self):
"""Return self as a binary string."""
entrylen = struct.calcsize(self.ENTRYSTRUCT)
rslt = []
for (dpos, dlen, ulen, flag, typcd, nm) in self.data:
nmlen = len(nm) + 1 # add 1 for a '\0'
# version 4
# rslt.append(struct.pack(se... | python | def tobinary(self):
"""Return self as a binary string."""
entrylen = struct.calcsize(self.ENTRYSTRUCT)
rslt = []
for (dpos, dlen, ulen, flag, typcd, nm) in self.data:
nmlen = len(nm) + 1 # add 1 for a '\0'
# version 4
# rslt.append(struct.pack(se... | [
"def",
"tobinary",
"(",
"self",
")",
":",
"entrylen",
"=",
"struct",
".",
"calcsize",
"(",
"self",
".",
"ENTRYSTRUCT",
")",
"rslt",
"=",
"[",
"]",
"for",
"(",
"dpos",
",",
"dlen",
",",
"ulen",
",",
"flag",
",",
"typcd",
",",
"nm",
")",
"in",
"sel... | Return self as a binary string. | [
"Return",
"self",
"as",
"a",
"binary",
"string",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py#L60-L82 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py | CTOC.add | def add(self, dpos, dlen, ulen, flag, typcd, nm):
"""Add an entry to the table of contents.
DPOS is data position.
DLEN is data length.
ULEN is the uncompressed data len.
FLAG says if the data is compressed.
TYPCD is the "type" of the entry (used by the C ... | python | def add(self, dpos, dlen, ulen, flag, typcd, nm):
"""Add an entry to the table of contents.
DPOS is data position.
DLEN is data length.
ULEN is the uncompressed data len.
FLAG says if the data is compressed.
TYPCD is the "type" of the entry (used by the C ... | [
"def",
"add",
"(",
"self",
",",
"dpos",
",",
"dlen",
",",
"ulen",
",",
"flag",
",",
"typcd",
",",
"nm",
")",
":",
"self",
".",
"data",
".",
"append",
"(",
"(",
"dpos",
",",
"dlen",
",",
"ulen",
",",
"flag",
",",
"typcd",
",",
"nm",
")",
")"
] | Add an entry to the table of contents.
DPOS is data position.
DLEN is data length.
ULEN is the uncompressed data len.
FLAG says if the data is compressed.
TYPCD is the "type" of the entry (used by the C code)
NM is the entry's name. | [
"Add",
"an",
"entry",
"to",
"the",
"table",
"of",
"contents",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py#L84-L93 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py | CTOC.find | def find(self, name):
"""Return the index of the toc entry with name NAME.
Return -1 for failure."""
for i, nm in enumerate(self.data):
if nm[-1] == name:
return i
return -1 | python | def find(self, name):
"""Return the index of the toc entry with name NAME.
Return -1 for failure."""
for i, nm in enumerate(self.data):
if nm[-1] == name:
return i
return -1 | [
"def",
"find",
"(",
"self",
",",
"name",
")",
":",
"for",
"i",
",",
"nm",
"in",
"enumerate",
"(",
"self",
".",
"data",
")",
":",
"if",
"nm",
"[",
"-",
"1",
"]",
"==",
"name",
":",
"return",
"i",
"return",
"-",
"1"
] | Return the index of the toc entry with name NAME.
Return -1 for failure. | [
"Return",
"the",
"index",
"of",
"the",
"toc",
"entry",
"with",
"name",
"NAME",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py#L102-L109 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py | CArchive.checkmagic | def checkmagic(self):
"""Verify that self is a valid CArchive.
Magic signature is at end of the archive."""
#magic is at EOF; if we're embedded, we need to figure where that is
if self.len:
self.lib.seek(self.start+self.len, 0)
else:
self.lib.seek(0, ... | python | def checkmagic(self):
"""Verify that self is a valid CArchive.
Magic signature is at end of the archive."""
#magic is at EOF; if we're embedded, we need to figure where that is
if self.len:
self.lib.seek(self.start+self.len, 0)
else:
self.lib.seek(0, ... | [
"def",
"checkmagic",
"(",
"self",
")",
":",
"if",
"self",
".",
"len",
":",
"self",
".",
"lib",
".",
"seek",
"(",
"self",
".",
"start",
"+",
"self",
".",
"len",
",",
"0",
")",
"else",
":",
"self",
".",
"lib",
".",
"seek",
"(",
"0",
",",
"2",
... | Verify that self is a valid CArchive.
Magic signature is at end of the archive. | [
"Verify",
"that",
"self",
"is",
"a",
"valid",
"CArchive",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py#L130-L153 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py | CArchive.loadtoc | def loadtoc(self):
"""Load the table of contents into memory."""
self.toc = self.TOCTMPLT()
self.lib.seek(self.pkgstart+self.tocpos)
tocstr = self.lib.read(self.toclen)
self.toc.frombinary(tocstr) | python | def loadtoc(self):
"""Load the table of contents into memory."""
self.toc = self.TOCTMPLT()
self.lib.seek(self.pkgstart+self.tocpos)
tocstr = self.lib.read(self.toclen)
self.toc.frombinary(tocstr) | [
"def",
"loadtoc",
"(",
"self",
")",
":",
"self",
".",
"toc",
"=",
"self",
".",
"TOCTMPLT",
"(",
")",
"self",
".",
"lib",
".",
"seek",
"(",
"self",
".",
"pkgstart",
"+",
"self",
".",
"tocpos",
")",
"tocstr",
"=",
"self",
".",
"lib",
".",
"read",
... | Load the table of contents into memory. | [
"Load",
"the",
"table",
"of",
"contents",
"into",
"memory",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py#L155-L160 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py | CArchive.extract | def extract(self, name):
"""Get the contents of an entry.
NAME is an entry name.
Return the tuple (ispkg, contents).
For non-Python resoures, ispkg is meaningless (and 0).
Used by the import mechanism."""
if type(name) == type(''):
ndx = self.toc.... | python | def extract(self, name):
"""Get the contents of an entry.
NAME is an entry name.
Return the tuple (ispkg, contents).
For non-Python resoures, ispkg is meaningless (and 0).
Used by the import mechanism."""
if type(name) == type(''):
ndx = self.toc.... | [
"def",
"extract",
"(",
"self",
",",
"name",
")",
":",
"if",
"type",
"(",
"name",
")",
"==",
"type",
"(",
"''",
")",
":",
"ndx",
"=",
"self",
".",
"toc",
".",
"find",
"(",
"name",
")",
"if",
"ndx",
"==",
"-",
"1",
":",
"return",
"None",
"else"... | Get the contents of an entry.
NAME is an entry name.
Return the tuple (ispkg, contents).
For non-Python resoures, ispkg is meaningless (and 0).
Used by the import mechanism. | [
"Get",
"the",
"contents",
"of",
"an",
"entry",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py#L162-L188 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py | CArchive.contents | def contents(self):
"""Return the names of the entries"""
rslt = []
for (dpos, dlen, ulen, flag, typcd, nm) in self.toc:
rslt.append(nm)
return rslt | python | def contents(self):
"""Return the names of the entries"""
rslt = []
for (dpos, dlen, ulen, flag, typcd, nm) in self.toc:
rslt.append(nm)
return rslt | [
"def",
"contents",
"(",
"self",
")",
":",
"rslt",
"=",
"[",
"]",
"for",
"(",
"dpos",
",",
"dlen",
",",
"ulen",
",",
"flag",
",",
"typcd",
",",
"nm",
")",
"in",
"self",
".",
"toc",
":",
"rslt",
".",
"append",
"(",
"nm",
")",
"return",
"rslt"
] | Return the names of the entries | [
"Return",
"the",
"names",
"of",
"the",
"entries"
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py#L190-L195 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py | CArchive.add | def add(self, entry):
"""Add an ENTRY to the CArchive.
ENTRY must have:
entry[0] is name (under which it will be saved).
entry[1] is fullpathname of the file.
entry[2] is a flag for it's storage format (0==uncompressed,
1==compressed)
... | python | def add(self, entry):
"""Add an ENTRY to the CArchive.
ENTRY must have:
entry[0] is name (under which it will be saved).
entry[1] is fullpathname of the file.
entry[2] is a flag for it's storage format (0==uncompressed,
1==compressed)
... | [
"def",
"add",
"(",
"self",
",",
"entry",
")",
":",
"(",
"nm",
",",
"pathnm",
",",
"flag",
",",
"typcd",
")",
"=",
"entry",
"[",
":",
"4",
"]",
"try",
":",
"if",
"typcd",
"in",
"(",
"'o'",
",",
"'d'",
")",
":",
"s",
"=",
"''",
"flag",
"=",
... | Add an ENTRY to the CArchive.
ENTRY must have:
entry[0] is name (under which it will be saved).
entry[1] is fullpathname of the file.
entry[2] is a flag for it's storage format (0==uncompressed,
1==compressed)
entry[3] is the entry's type code... | [
"Add",
"an",
"ENTRY",
"to",
"the",
"CArchive",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py#L197-L245 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py | CArchive.save_toc | def save_toc(self, tocpos):
"""Save the table of contents to disk."""
self.tocpos = tocpos
tocstr = self.toc.tobinary()
self.toclen = len(tocstr)
self.lib.write(tocstr) | python | def save_toc(self, tocpos):
"""Save the table of contents to disk."""
self.tocpos = tocpos
tocstr = self.toc.tobinary()
self.toclen = len(tocstr)
self.lib.write(tocstr) | [
"def",
"save_toc",
"(",
"self",
",",
"tocpos",
")",
":",
"self",
".",
"tocpos",
"=",
"tocpos",
"tocstr",
"=",
"self",
".",
"toc",
".",
"tobinary",
"(",
")",
"self",
".",
"toclen",
"=",
"len",
"(",
"tocstr",
")",
"self",
".",
"lib",
".",
"write",
... | Save the table of contents to disk. | [
"Save",
"the",
"table",
"of",
"contents",
"to",
"disk",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py#L247-L252 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py | CArchive.save_trailer | def save_trailer(self, tocpos):
"""Save the trailer to disk.
CArchives can be opened from the end - the trailer points
back to the start. """
totallen = tocpos + self.toclen + self.TRLLEN
pyvers = sys.version_info[0]*10 + sys.version_info[1]
trl = struct.pack(self.... | python | def save_trailer(self, tocpos):
"""Save the trailer to disk.
CArchives can be opened from the end - the trailer points
back to the start. """
totallen = tocpos + self.toclen + self.TRLLEN
pyvers = sys.version_info[0]*10 + sys.version_info[1]
trl = struct.pack(self.... | [
"def",
"save_trailer",
"(",
"self",
",",
"tocpos",
")",
":",
"totallen",
"=",
"tocpos",
"+",
"self",
".",
"toclen",
"+",
"self",
".",
"TRLLEN",
"pyvers",
"=",
"sys",
".",
"version_info",
"[",
"0",
"]",
"*",
"10",
"+",
"sys",
".",
"version_info",
"[",... | Save the trailer to disk.
CArchives can be opened from the end - the trailer points
back to the start. | [
"Save",
"the",
"trailer",
"to",
"disk",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py#L254-L263 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py | CArchive.openEmbedded | def openEmbedded(self, name):
"""Open a CArchive of name NAME embedded within this CArchive."""
ndx = self.toc.find(name)
if ndx == -1:
raise KeyError, "Member '%s' not found in %s" % (name, self.path)
(dpos, dlen, ulen, flag, typcd, nm) = self.toc.get(ndx)
if flag:
... | python | def openEmbedded(self, name):
"""Open a CArchive of name NAME embedded within this CArchive."""
ndx = self.toc.find(name)
if ndx == -1:
raise KeyError, "Member '%s' not found in %s" % (name, self.path)
(dpos, dlen, ulen, flag, typcd, nm) = self.toc.get(ndx)
if flag:
... | [
"def",
"openEmbedded",
"(",
"self",
",",
"name",
")",
":",
"ndx",
"=",
"self",
".",
"toc",
".",
"find",
"(",
"name",
")",
"if",
"ndx",
"==",
"-",
"1",
":",
"raise",
"KeyError",
",",
"\"Member '%s' not found in %s\"",
"%",
"(",
"name",
",",
"self",
".... | Open a CArchive of name NAME embedded within this CArchive. | [
"Open",
"a",
"CArchive",
"of",
"name",
"NAME",
"embedded",
"within",
"this",
"CArchive",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/loader/carchive.py#L265-L273 | train |
bwhite/hadoopy | hadoopy/_runner.py | _find_hstreaming | def _find_hstreaming():
"""Finds the whole path to the hadoop streaming jar.
If the environmental var HADOOP_HOME is specified, then start the search
from there.
Returns:
Full path to the hadoop streaming jar if found, else return an empty
string.
"""
global WARNED_HADOOP_HOME,... | python | def _find_hstreaming():
"""Finds the whole path to the hadoop streaming jar.
If the environmental var HADOOP_HOME is specified, then start the search
from there.
Returns:
Full path to the hadoop streaming jar if found, else return an empty
string.
"""
global WARNED_HADOOP_HOME,... | [
"def",
"_find_hstreaming",
"(",
")",
":",
"global",
"WARNED_HADOOP_HOME",
",",
"HADOOP_STREAMING_PATH_CACHE",
"if",
"HADOOP_STREAMING_PATH_CACHE",
":",
"return",
"HADOOP_STREAMING_PATH_CACHE",
"try",
":",
"search_root",
"=",
"os",
".",
"environ",
"[",
"'HADOOP_HOME'",
"... | Finds the whole path to the hadoop streaming jar.
If the environmental var HADOOP_HOME is specified, then start the search
from there.
Returns:
Full path to the hadoop streaming jar if found, else return an empty
string. | [
"Finds",
"the",
"whole",
"path",
"to",
"the",
"hadoop",
"streaming",
"jar",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/_runner.py#L38-L63 | train |
bwhite/hadoopy | hadoopy/_runner.py | _listeq_to_dict | def _listeq_to_dict(jobconfs):
"""Convert iterators of 'key=val' into a dictionary with later values taking priority."""
if not isinstance(jobconfs, dict):
jobconfs = dict(x.split('=', 1) for x in jobconfs)
return dict((str(k), str(v)) for k, v in jobconfs.items()) | python | def _listeq_to_dict(jobconfs):
"""Convert iterators of 'key=val' into a dictionary with later values taking priority."""
if not isinstance(jobconfs, dict):
jobconfs = dict(x.split('=', 1) for x in jobconfs)
return dict((str(k), str(v)) for k, v in jobconfs.items()) | [
"def",
"_listeq_to_dict",
"(",
"jobconfs",
")",
":",
"if",
"not",
"isinstance",
"(",
"jobconfs",
",",
"dict",
")",
":",
"jobconfs",
"=",
"dict",
"(",
"x",
".",
"split",
"(",
"'='",
",",
"1",
")",
"for",
"x",
"in",
"jobconfs",
")",
"return",
"dict",
... | Convert iterators of 'key=val' into a dictionary with later values taking priority. | [
"Convert",
"iterators",
"of",
"key",
"=",
"val",
"into",
"a",
"dictionary",
"with",
"later",
"values",
"taking",
"priority",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/_runner.py#L66-L70 | train |
bwhite/hadoopy | hadoopy/_runner.py | launch_frozen | def launch_frozen(in_name, out_name, script_path, frozen_tar_path=None,
temp_path='_hadoopy_temp', cache=True, check_script=False,
**kw):
"""Freezes a script and then launches it.
This function will freeze your python program, and place it on HDFS
in 'temp_path'. It wil... | python | def launch_frozen(in_name, out_name, script_path, frozen_tar_path=None,
temp_path='_hadoopy_temp', cache=True, check_script=False,
**kw):
"""Freezes a script and then launches it.
This function will freeze your python program, and place it on HDFS
in 'temp_path'. It wil... | [
"def",
"launch_frozen",
"(",
"in_name",
",",
"out_name",
",",
"script_path",
",",
"frozen_tar_path",
"=",
"None",
",",
"temp_path",
"=",
"'_hadoopy_temp'",
",",
"cache",
"=",
"True",
",",
"check_script",
"=",
"False",
",",
"**",
"kw",
")",
":",
"if",
"(",
... | Freezes a script and then launches it.
This function will freeze your python program, and place it on HDFS
in 'temp_path'. It will not remove it afterwards as they are typically
small, you can easily reuse/debug them, and to avoid any risks involved
with removing the file.
:param in_name: Input p... | [
"Freezes",
"a",
"script",
"and",
"then",
"launches",
"it",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/_runner.py#L341-L410 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/depend/dylib.py | include_library | def include_library(libname):
"""Check if a dynamic library should be included with application or not."""
# For configuration phase we need to have exclude / include lists None
# so these checking is skipped and library gets included.
if exclude_list:
if exclude_list.search(libname) and not inc... | python | def include_library(libname):
"""Check if a dynamic library should be included with application or not."""
# For configuration phase we need to have exclude / include lists None
# so these checking is skipped and library gets included.
if exclude_list:
if exclude_list.search(libname) and not inc... | [
"def",
"include_library",
"(",
"libname",
")",
":",
"if",
"exclude_list",
":",
"if",
"exclude_list",
".",
"search",
"(",
"libname",
")",
"and",
"not",
"include_list",
".",
"search",
"(",
"libname",
")",
":",
"return",
"False",
"else",
":",
"return",
"True"... | Check if a dynamic library should be included with application or not. | [
"Check",
"if",
"a",
"dynamic",
"library",
"should",
"be",
"included",
"with",
"application",
"or",
"not",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/depend/dylib.py#L158-L172 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/depend/dylib.py | mac_set_relative_dylib_deps | def mac_set_relative_dylib_deps(libname):
"""
On Mac OS X set relative paths to dynamic library dependencies of `libname`.
Relative paths allow to avoid using environment variable DYLD_LIBRARY_PATH.
There are known some issues with DYLD_LIBRARY_PATH. Relative paths is
more flexible mechanism.
... | python | def mac_set_relative_dylib_deps(libname):
"""
On Mac OS X set relative paths to dynamic library dependencies of `libname`.
Relative paths allow to avoid using environment variable DYLD_LIBRARY_PATH.
There are known some issues with DYLD_LIBRARY_PATH. Relative paths is
more flexible mechanism.
... | [
"def",
"mac_set_relative_dylib_deps",
"(",
"libname",
")",
":",
"from",
"PyInstaller",
".",
"lib",
".",
"macholib",
"import",
"util",
"from",
"PyInstaller",
".",
"lib",
".",
"macholib",
".",
"MachO",
"import",
"MachO",
"if",
"os",
".",
"path",
".",
"basename... | On Mac OS X set relative paths to dynamic library dependencies of `libname`.
Relative paths allow to avoid using environment variable DYLD_LIBRARY_PATH.
There are known some issues with DYLD_LIBRARY_PATH. Relative paths is
more flexible mechanism.
Current location of dependend libraries is derived fro... | [
"On",
"Mac",
"OS",
"X",
"set",
"relative",
"paths",
"to",
"dynamic",
"library",
"dependencies",
"of",
"libname",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/depend/dylib.py#L175-L222 | train |
roycehaynes/scrapy-rabbitmq | scrapy_rabbitmq/connection.py | from_settings | def from_settings(settings):
""" Factory method that returns an instance of channel
:param str connection_type: This field can be `blocking`
`asyncore`, `libev`, `select`, `tornado`, or `twisted`
See pika documentation for more details:
TODO: put pika url regarding connecti... | python | def from_settings(settings):
""" Factory method that returns an instance of channel
:param str connection_type: This field can be `blocking`
`asyncore`, `libev`, `select`, `tornado`, or `twisted`
See pika documentation for more details:
TODO: put pika url regarding connecti... | [
"def",
"from_settings",
"(",
"settings",
")",
":",
"connection_type",
"=",
"settings",
".",
"get",
"(",
"'RABBITMQ_CONNECTION_TYPE'",
",",
"RABBITMQ_CONNECTION_TYPE",
")",
"queue_name",
"=",
"settings",
".",
"get",
"(",
"'RABBITMQ_QUEUE_NAME'",
",",
"RABBITMQ_QUEUE_NA... | Factory method that returns an instance of channel
:param str connection_type: This field can be `blocking`
`asyncore`, `libev`, `select`, `tornado`, or `twisted`
See pika documentation for more details:
TODO: put pika url regarding connection type
Parameters is a dict... | [
"Factory",
"method",
"that",
"returns",
"an",
"instance",
"of",
"channel"
] | 5053b500aff1d6679cc0e3d3e338c2bf74fadc22 | https://github.com/roycehaynes/scrapy-rabbitmq/blob/5053b500aff1d6679cc0e3d3e338c2bf74fadc22/scrapy_rabbitmq/connection.py#L14-L59 | train |
roycehaynes/scrapy-rabbitmq | scrapy_rabbitmq/spiders.py | RabbitMQMixin.setup_rabbitmq | def setup_rabbitmq(self):
""" Setup RabbitMQ connection.
Call this method after spider has set its crawler object.
:return: None
"""
if not self.rabbitmq_key:
self.rabbitmq_key = '{}:start_urls'.format(self.name)
self.server = connection.from_settings(s... | python | def setup_rabbitmq(self):
""" Setup RabbitMQ connection.
Call this method after spider has set its crawler object.
:return: None
"""
if not self.rabbitmq_key:
self.rabbitmq_key = '{}:start_urls'.format(self.name)
self.server = connection.from_settings(s... | [
"def",
"setup_rabbitmq",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"rabbitmq_key",
":",
"self",
".",
"rabbitmq_key",
"=",
"'{}:start_urls'",
".",
"format",
"(",
"self",
".",
"name",
")",
"self",
".",
"server",
"=",
"connection",
".",
"from_settings"... | Setup RabbitMQ connection.
Call this method after spider has set its crawler object.
:return: None | [
"Setup",
"RabbitMQ",
"connection",
"."
] | 5053b500aff1d6679cc0e3d3e338c2bf74fadc22 | https://github.com/roycehaynes/scrapy-rabbitmq/blob/5053b500aff1d6679cc0e3d3e338c2bf74fadc22/scrapy_rabbitmq/spiders.py#L19-L31 | train |
roycehaynes/scrapy-rabbitmq | scrapy_rabbitmq/spiders.py | RabbitMQMixin.schedule_next_request | def schedule_next_request(self):
""" Schedules a request, if exists.
:return:
"""
req = self.next_request()
if req:
self.crawler.engine.crawl(req, spider=self) | python | def schedule_next_request(self):
""" Schedules a request, if exists.
:return:
"""
req = self.next_request()
if req:
self.crawler.engine.crawl(req, spider=self) | [
"def",
"schedule_next_request",
"(",
"self",
")",
":",
"req",
"=",
"self",
".",
"next_request",
"(",
")",
"if",
"req",
":",
"self",
".",
"crawler",
".",
"engine",
".",
"crawl",
"(",
"req",
",",
"spider",
"=",
"self",
")"
] | Schedules a request, if exists.
:return: | [
"Schedules",
"a",
"request",
"if",
"exists",
"."
] | 5053b500aff1d6679cc0e3d3e338c2bf74fadc22 | https://github.com/roycehaynes/scrapy-rabbitmq/blob/5053b500aff1d6679cc0e3d3e338c2bf74fadc22/scrapy_rabbitmq/spiders.py#L46-L54 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py | set_flags | def set_flags(obj, flag_field, flags):
"""Will process the flags and set attributes in the object accordingly.
The object "obj" will gain attributes named after the flags provided in
"flags" and valued True/False, matching the results of applying each
flag value from "flags" to flag_field.
"""
... | python | def set_flags(obj, flag_field, flags):
"""Will process the flags and set attributes in the object accordingly.
The object "obj" will gain attributes named after the flags provided in
"flags" and valued True/False, matching the results of applying each
flag value from "flags" to flag_field.
"""
... | [
"def",
"set_flags",
"(",
"obj",
",",
"flag_field",
",",
"flags",
")",
":",
"for",
"flag",
"in",
"flags",
":",
"if",
"flag",
"[",
"1",
"]",
"&",
"flag_field",
":",
"obj",
".",
"__dict__",
"[",
"flag",
"[",
"0",
"]",
"]",
"=",
"True",
"else",
":",
... | Will process the flags and set attributes in the object accordingly.
The object "obj" will gain attributes named after the flags provided in
"flags" and valued True/False, matching the results of applying each
flag value from "flags" to flag_field. | [
"Will",
"process",
"the",
"flags",
"and",
"set",
"attributes",
"in",
"the",
"object",
"accordingly",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py#L559-L573 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py | UnicodeStringWrapperPostProcessor.ask_pascal_16 | def ask_pascal_16(self, next_rva_ptr):
"""The next RVA is taken to be the one immediately following this one.
Such RVA could indicate the natural end of the string and will be checked
with the possible length contained in the first word.
"""
length = self.__get_... | python | def ask_pascal_16(self, next_rva_ptr):
"""The next RVA is taken to be the one immediately following this one.
Such RVA could indicate the natural end of the string and will be checked
with the possible length contained in the first word.
"""
length = self.__get_... | [
"def",
"ask_pascal_16",
"(",
"self",
",",
"next_rva_ptr",
")",
":",
"length",
"=",
"self",
".",
"__get_pascal_16_length",
"(",
")",
"if",
"length",
"==",
"(",
"next_rva_ptr",
"-",
"(",
"self",
".",
"rva_ptr",
"+",
"2",
")",
")",
"/",
"2",
":",
"self",
... | The next RVA is taken to be the one immediately following this one.
Such RVA could indicate the natural end of the string and will be checked
with the possible length contained in the first word. | [
"The",
"next",
"RVA",
"is",
"taken",
"to",
"be",
"the",
"one",
"immediately",
"following",
"this",
"one",
".",
"Such",
"RVA",
"could",
"indicate",
"the",
"natural",
"end",
"of",
"the",
"string",
"and",
"will",
"be",
"checked",
"with",
"the",
"possible",
... | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py#L663-L676 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py | Dump.add | def add(self, txt, indent=0):
"""Adds some text, no newline will be appended.
The text can be indented with the optional argument 'indent'.
"""
if isinstance(txt, unicode):
try:
txt = str(txt)
except UnicodeEncodeError:
... | python | def add(self, txt, indent=0):
"""Adds some text, no newline will be appended.
The text can be indented with the optional argument 'indent'.
"""
if isinstance(txt, unicode):
try:
txt = str(txt)
except UnicodeEncodeError:
... | [
"def",
"add",
"(",
"self",
",",
"txt",
",",
"indent",
"=",
"0",
")",
":",
"if",
"isinstance",
"(",
"txt",
",",
"unicode",
")",
":",
"try",
":",
"txt",
"=",
"str",
"(",
"txt",
")",
"except",
"UnicodeEncodeError",
":",
"s",
"=",
"[",
"]",
"for",
... | Adds some text, no newline will be appended.
The text can be indented with the optional argument 'indent'. | [
"Adds",
"some",
"text",
"no",
"newline",
"will",
"be",
"appended",
".",
"The",
"text",
"can",
"be",
"indented",
"with",
"the",
"optional",
"argument",
"indent",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py#L756-L775 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py | SectionStructure.contains_offset | def contains_offset(self, offset):
"""Check whether the section contains the file offset provided."""
if self.PointerToRawData is None:
# bss and other sections containing only uninitialized data must have 0
# and do not take space in the file
return False
... | python | def contains_offset(self, offset):
"""Check whether the section contains the file offset provided."""
if self.PointerToRawData is None:
# bss and other sections containing only uninitialized data must have 0
# and do not take space in the file
return False
... | [
"def",
"contains_offset",
"(",
"self",
",",
"offset",
")",
":",
"if",
"self",
".",
"PointerToRawData",
"is",
"None",
":",
"return",
"False",
"return",
"(",
"adjust_FileAlignment",
"(",
"self",
".",
"PointerToRawData",
",",
"self",
".",
"pe",
".",
"OPTIONAL_H... | Check whether the section contains the file offset provided. | [
"Check",
"whether",
"the",
"section",
"contains",
"the",
"file",
"offset",
"provided",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py#L1052-L1064 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py | PE.parse_resource_entry | def parse_resource_entry(self, rva):
"""Parse a directory entry from the resources directory."""
try:
data = self.get_data( rva, Structure(self.__IMAGE_RESOURCE_DIRECTORY_ENTRY_format__).sizeof() )
except PEFormatError, excp:
# A warning will be added by the caller if th... | python | def parse_resource_entry(self, rva):
"""Parse a directory entry from the resources directory."""
try:
data = self.get_data( rva, Structure(self.__IMAGE_RESOURCE_DIRECTORY_ENTRY_format__).sizeof() )
except PEFormatError, excp:
# A warning will be added by the caller if th... | [
"def",
"parse_resource_entry",
"(",
"self",
",",
"rva",
")",
":",
"try",
":",
"data",
"=",
"self",
".",
"get_data",
"(",
"rva",
",",
"Structure",
"(",
"self",
".",
"__IMAGE_RESOURCE_DIRECTORY_ENTRY_format__",
")",
".",
"sizeof",
"(",
")",
")",
"except",
"P... | Parse a directory entry from the resources directory. | [
"Parse",
"a",
"directory",
"entry",
"from",
"the",
"resources",
"directory",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py#L2790-L2815 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py | PE.parse_imports | def parse_imports(self, original_first_thunk, first_thunk, forwarder_chain):
"""Parse the imported symbols.
It will fill a list, which will be available as the dictionary
attribute "imports". Its keys will be the DLL names and the values
all the symbols imported from that object... | python | def parse_imports(self, original_first_thunk, first_thunk, forwarder_chain):
"""Parse the imported symbols.
It will fill a list, which will be available as the dictionary
attribute "imports". Its keys will be the DLL names and the values
all the symbols imported from that object... | [
"def",
"parse_imports",
"(",
"self",
",",
"original_first_thunk",
",",
"first_thunk",
",",
"forwarder_chain",
")",
":",
"imported_symbols",
"=",
"[",
"]",
"ilt",
"=",
"self",
".",
"get_import_table",
"(",
"original_first_thunk",
")",
"iat",
"=",
"self",
".",
"... | Parse the imported symbols.
It will fill a list, which will be available as the dictionary
attribute "imports". Its keys will be the DLL names and the values
all the symbols imported from that object. | [
"Parse",
"the",
"imported",
"symbols",
".",
"It",
"will",
"fill",
"a",
"list",
"which",
"will",
"be",
"available",
"as",
"the",
"dictionary",
"attribute",
"imports",
".",
"Its",
"keys",
"will",
"be",
"the",
"DLL",
"names",
"and",
"the",
"values",
"all",
... | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py#L3437-L3565 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py | PE.get_data | def get_data(self, rva=0, length=None):
"""Get data regardless of the section where it lies on.
Given a RVA and the size of the chunk to retrieve, this method
will find the section where the data lies and return the data.
"""
s = self.get_section_by_rva(rva)
... | python | def get_data(self, rva=0, length=None):
"""Get data regardless of the section where it lies on.
Given a RVA and the size of the chunk to retrieve, this method
will find the section where the data lies and return the data.
"""
s = self.get_section_by_rva(rva)
... | [
"def",
"get_data",
"(",
"self",
",",
"rva",
"=",
"0",
",",
"length",
"=",
"None",
")",
":",
"s",
"=",
"self",
".",
"get_section_by_rva",
"(",
"rva",
")",
"if",
"length",
":",
"end",
"=",
"rva",
"+",
"length",
"else",
":",
"end",
"=",
"None",
"if"... | Get data regardless of the section where it lies on.
Given a RVA and the size of the chunk to retrieve, this method
will find the section where the data lies and return the data. | [
"Get",
"data",
"regardless",
"of",
"the",
"section",
"where",
"it",
"lies",
"on",
".",
"Given",
"a",
"RVA",
"and",
"the",
"size",
"of",
"the",
"chunk",
"to",
"retrieve",
"this",
"method",
"will",
"find",
"the",
"section",
"where",
"the",
"data",
"lies",
... | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py#L3711-L3743 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py | PE.get_rva_from_offset | def get_rva_from_offset(self, offset):
"""Get the RVA corresponding to this file offset. """
s = self.get_section_by_offset(offset)
if not s:
if self.sections:
lowest_rva = min( [ adjust_SectionAlignment( s.VirtualAddress,
self.OPTIONAL_H... | python | def get_rva_from_offset(self, offset):
"""Get the RVA corresponding to this file offset. """
s = self.get_section_by_offset(offset)
if not s:
if self.sections:
lowest_rva = min( [ adjust_SectionAlignment( s.VirtualAddress,
self.OPTIONAL_H... | [
"def",
"get_rva_from_offset",
"(",
"self",
",",
"offset",
")",
":",
"s",
"=",
"self",
".",
"get_section_by_offset",
"(",
"offset",
")",
"if",
"not",
"s",
":",
"if",
"self",
".",
"sections",
":",
"lowest_rva",
"=",
"min",
"(",
"[",
"adjust_SectionAlignment"... | Get the RVA corresponding to this file offset. | [
"Get",
"the",
"RVA",
"corresponding",
"to",
"this",
"file",
"offset",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py#L3746-L3767 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py | PE.get_offset_from_rva | def get_offset_from_rva(self, rva):
"""Get the file offset corresponding to this RVA.
Given a RVA , this method will find the section where the
data lies and return the offset within the file.
"""
s = self.get_section_by_rva(rva)
if not s:
#... | python | def get_offset_from_rva(self, rva):
"""Get the file offset corresponding to this RVA.
Given a RVA , this method will find the section where the
data lies and return the offset within the file.
"""
s = self.get_section_by_rva(rva)
if not s:
#... | [
"def",
"get_offset_from_rva",
"(",
"self",
",",
"rva",
")",
":",
"s",
"=",
"self",
".",
"get_section_by_rva",
"(",
"rva",
")",
"if",
"not",
"s",
":",
"if",
"rva",
"<",
"len",
"(",
"self",
".",
"__data__",
")",
":",
"return",
"rva",
"raise",
"PEFormat... | Get the file offset corresponding to this RVA.
Given a RVA , this method will find the section where the
data lies and return the offset within the file. | [
"Get",
"the",
"file",
"offset",
"corresponding",
"to",
"this",
"RVA",
".",
"Given",
"a",
"RVA",
"this",
"method",
"will",
"find",
"the",
"section",
"where",
"the",
"data",
"lies",
"and",
"return",
"the",
"offset",
"within",
"the",
"file",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py#L3769-L3788 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py | PE.get_string_at_rva | def get_string_at_rva(self, rva):
"""Get an ASCII string located at the given address."""
s = self.get_section_by_rva(rva)
if not s:
return self.get_string_from_data(0, self.__data__[rva:rva+MAX_STRING_LENGTH])
return self.get_string_from_data( 0, s.get_data(rva, le... | python | def get_string_at_rva(self, rva):
"""Get an ASCII string located at the given address."""
s = self.get_section_by_rva(rva)
if not s:
return self.get_string_from_data(0, self.__data__[rva:rva+MAX_STRING_LENGTH])
return self.get_string_from_data( 0, s.get_data(rva, le... | [
"def",
"get_string_at_rva",
"(",
"self",
",",
"rva",
")",
":",
"s",
"=",
"self",
".",
"get_section_by_rva",
"(",
"rva",
")",
"if",
"not",
"s",
":",
"return",
"self",
".",
"get_string_from_data",
"(",
"0",
",",
"self",
".",
"__data__",
"[",
"rva",
":",
... | Get an ASCII string located at the given address. | [
"Get",
"an",
"ASCII",
"string",
"located",
"at",
"the",
"given",
"address",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py#L3791-L3798 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py | PE.get_string_from_data | def get_string_from_data(self, offset, data):
"""Get an ASCII string from within the data."""
# OC Patch
b = None
try:
b = data[offset]
except IndexError:
return ''
s = ''
while ord(b):
s += b
... | python | def get_string_from_data(self, offset, data):
"""Get an ASCII string from within the data."""
# OC Patch
b = None
try:
b = data[offset]
except IndexError:
return ''
s = ''
while ord(b):
s += b
... | [
"def",
"get_string_from_data",
"(",
"self",
",",
"offset",
",",
"data",
")",
":",
"b",
"=",
"None",
"try",
":",
"b",
"=",
"data",
"[",
"offset",
"]",
"except",
"IndexError",
":",
"return",
"''",
"s",
"=",
"''",
"while",
"ord",
"(",
"b",
")",
":",
... | Get an ASCII string from within the data. | [
"Get",
"an",
"ASCII",
"string",
"from",
"within",
"the",
"data",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py#L3801-L3821 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py | PE.set_bytes_at_rva | def set_bytes_at_rva(self, rva, data):
"""Overwrite, with the given string, the bytes at the file offset corresponding to the given RVA.
Return True if successful, False otherwise. It can fail if the
offset is outside the file's boundaries.
"""
offset = self.get... | python | def set_bytes_at_rva(self, rva, data):
"""Overwrite, with the given string, the bytes at the file offset corresponding to the given RVA.
Return True if successful, False otherwise. It can fail if the
offset is outside the file's boundaries.
"""
offset = self.get... | [
"def",
"set_bytes_at_rva",
"(",
"self",
",",
"rva",
",",
"data",
")",
":",
"offset",
"=",
"self",
".",
"get_physical_by_rva",
"(",
"rva",
")",
"if",
"not",
"offset",
":",
"raise",
"False",
"return",
"self",
".",
"set_bytes_at_offset",
"(",
"offset",
",",
... | Overwrite, with the given string, the bytes at the file offset corresponding to the given RVA.
Return True if successful, False otherwise. It can fail if the
offset is outside the file's boundaries. | [
"Overwrite",
"with",
"the",
"given",
"string",
"the",
"bytes",
"at",
"the",
"file",
"offset",
"corresponding",
"to",
"the",
"given",
"RVA",
".",
"Return",
"True",
"if",
"successful",
"False",
"otherwise",
".",
"It",
"can",
"fail",
"if",
"the",
"offset",
"i... | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py#L4367-L4378 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py | PE.merge_modified_section_data | def merge_modified_section_data(self):
"""Update the PE image content with any individual section data that has been modified."""
for section in self.sections:
section_data_start = adjust_FileAlignment( section.PointerToRawData,
self.OPTIONAL_HEADER.FileAlignment )
... | python | def merge_modified_section_data(self):
"""Update the PE image content with any individual section data that has been modified."""
for section in self.sections:
section_data_start = adjust_FileAlignment( section.PointerToRawData,
self.OPTIONAL_HEADER.FileAlignment )
... | [
"def",
"merge_modified_section_data",
"(",
"self",
")",
":",
"for",
"section",
"in",
"self",
".",
"sections",
":",
"section_data_start",
"=",
"adjust_FileAlignment",
"(",
"section",
".",
"PointerToRawData",
",",
"self",
".",
"OPTIONAL_HEADER",
".",
"FileAlignment",
... | Update the PE image content with any individual section data that has been modified. | [
"Update",
"the",
"PE",
"image",
"content",
"with",
"any",
"individual",
"section",
"data",
"that",
"has",
"been",
"modified",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py#L4399-L4407 | train |
bwhite/hadoopy | hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py | PE.is_driver | def is_driver(self):
"""Check whether the file is a Windows driver.
This will return true only if there are reliable indicators of the image
being a driver.
"""
# Checking that the ImageBase field of the OptionalHeader is above or
# equal to 0x80000000 (that is,... | python | def is_driver(self):
"""Check whether the file is a Windows driver.
This will return true only if there are reliable indicators of the image
being a driver.
"""
# Checking that the ImageBase field of the OptionalHeader is above or
# equal to 0x80000000 (that is,... | [
"def",
"is_driver",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"'DIRECTORY_ENTRY_IMPORT'",
")",
":",
"if",
"set",
"(",
"(",
"'ntoskrnl.exe'",
",",
"'hal.dll'",
",",
"'ndis.sys'",
",",
"'bootvid.dll'",
",",
"'kdcom.dll'",
")",
")",
".",
"inte... | Check whether the file is a Windows driver.
This will return true only if there are reliable indicators of the image
being a driver. | [
"Check",
"whether",
"the",
"file",
"is",
"a",
"Windows",
"driver",
".",
"This",
"will",
"return",
"true",
"only",
"if",
"there",
"are",
"reliable",
"indicators",
"of",
"the",
"image",
"being",
"a",
"driver",
"."
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/thirdparty/pyinstaller/PyInstaller/lib/pefile.py#L4580-L4606 | train |
bwhite/hadoopy | hadoopy/_freeze.py | _copytree | def _copytree(src, dst):
"""Similar to shutils.copytree, except that dst is already there
"""
try:
os.makedirs(dst)
except OSError:
pass # It must already exist
for file in os.listdir(src):
try:
shutil.copy2('%s/%s' % (src, file), '%s/%s' % (dst, file))
e... | python | def _copytree(src, dst):
"""Similar to shutils.copytree, except that dst is already there
"""
try:
os.makedirs(dst)
except OSError:
pass # It must already exist
for file in os.listdir(src):
try:
shutil.copy2('%s/%s' % (src, file), '%s/%s' % (dst, file))
e... | [
"def",
"_copytree",
"(",
"src",
",",
"dst",
")",
":",
"try",
":",
"os",
".",
"makedirs",
"(",
"dst",
")",
"except",
"OSError",
":",
"pass",
"for",
"file",
"in",
"os",
".",
"listdir",
"(",
"src",
")",
":",
"try",
":",
"shutil",
".",
"copy2",
"(",
... | Similar to shutils.copytree, except that dst is already there | [
"Similar",
"to",
"shutils",
".",
"copytree",
"except",
"that",
"dst",
"is",
"already",
"there"
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/_freeze.py#L53-L67 | train |
bwhite/hadoopy | hadoopy/_freeze.py | _md5_file | def _md5_file(fn, block_size=1048576):
"""Builds the MD5 of a file block by block
Args:
fn: File path
block_size: Size of the blocks to consider (default 1048576)
Returns:
File MD5
"""
h = hashlib.md5()
with open(fn) as fp:
d = 1
while d:
d =... | python | def _md5_file(fn, block_size=1048576):
"""Builds the MD5 of a file block by block
Args:
fn: File path
block_size: Size of the blocks to consider (default 1048576)
Returns:
File MD5
"""
h = hashlib.md5()
with open(fn) as fp:
d = 1
while d:
d =... | [
"def",
"_md5_file",
"(",
"fn",
",",
"block_size",
"=",
"1048576",
")",
":",
"h",
"=",
"hashlib",
".",
"md5",
"(",
")",
"with",
"open",
"(",
"fn",
")",
"as",
"fp",
":",
"d",
"=",
"1",
"while",
"d",
":",
"d",
"=",
"fp",
".",
"read",
"(",
"block... | Builds the MD5 of a file block by block
Args:
fn: File path
block_size: Size of the blocks to consider (default 1048576)
Returns:
File MD5 | [
"Builds",
"the",
"MD5",
"of",
"a",
"file",
"block",
"by",
"block"
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/_freeze.py#L70-L86 | train |
bwhite/hadoopy | hadoopy/_freeze.py | freeze_script | def freeze_script(script_path, cache=True, temp_path='_hadoopy_temp'):
"""Freezes a script, puts it on hdfs, and gives you the path
'frozen_tar_path' can be given to launch_frozen and it will use that
instead of making its own, this is useful for repeated calls. If a
file with the same md5 already exi... | python | def freeze_script(script_path, cache=True, temp_path='_hadoopy_temp'):
"""Freezes a script, puts it on hdfs, and gives you the path
'frozen_tar_path' can be given to launch_frozen and it will use that
instead of making its own, this is useful for repeated calls. If a
file with the same md5 already exi... | [
"def",
"freeze_script",
"(",
"script_path",
",",
"cache",
"=",
"True",
",",
"temp_path",
"=",
"'_hadoopy_temp'",
")",
":",
"script_abspath",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"script_path",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"... | Freezes a script, puts it on hdfs, and gives you the path
'frozen_tar_path' can be given to launch_frozen and it will use that
instead of making its own, this is useful for repeated calls. If a
file with the same md5 already exists in the temp_path, it is used
instead of putting a new copy there to av... | [
"Freezes",
"a",
"script",
"puts",
"it",
"on",
"hdfs",
"and",
"gives",
"you",
"the",
"path"
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/_freeze.py#L92-L137 | train |
bwhite/hadoopy | hadoopy/_freeze.py | freeze | def freeze(script_path, target_dir='frozen', **kw):
"""Wraps pyinstaller and provides an easy to use interface
Args:
script_path: Absolute path to python script to be frozen.
Returns:
List of freeze commands ran
Raises:
subprocess.CalledProcessError: Freeze error.
OSEr... | python | def freeze(script_path, target_dir='frozen', **kw):
"""Wraps pyinstaller and provides an easy to use interface
Args:
script_path: Absolute path to python script to be frozen.
Returns:
List of freeze commands ran
Raises:
subprocess.CalledProcessError: Freeze error.
OSEr... | [
"def",
"freeze",
"(",
"script_path",
",",
"target_dir",
"=",
"'frozen'",
",",
"**",
"kw",
")",
":",
"cmds",
"=",
"[",
"]",
"freeze_start_time",
"=",
"time",
".",
"time",
"(",
")",
"logging",
".",
"debug",
"(",
"'/\\\\%s%s Output%s/\\\\'",
"%",
"(",
"'-'"... | Wraps pyinstaller and provides an easy to use interface
Args:
script_path: Absolute path to python script to be frozen.
Returns:
List of freeze commands ran
Raises:
subprocess.CalledProcessError: Freeze error.
OSError: Freeze not found. | [
"Wraps",
"pyinstaller",
"and",
"provides",
"an",
"easy",
"to",
"use",
"interface"
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/_freeze.py#L156-L188 | train |
bwhite/hadoopy | hadoopy/_freeze.py | freeze_to_tar | def freeze_to_tar(script_path, freeze_fn, extra_files=None):
"""Freezes a script to a .tar or .tar.gz file
The script contains all of the files at the root of the tar
Args:
script_path: Path to python script to be frozen.
freeze_fn: Tar filename (must end in .tar or .tar.gz)
extra_... | python | def freeze_to_tar(script_path, freeze_fn, extra_files=None):
"""Freezes a script to a .tar or .tar.gz file
The script contains all of the files at the root of the tar
Args:
script_path: Path to python script to be frozen.
freeze_fn: Tar filename (must end in .tar or .tar.gz)
extra_... | [
"def",
"freeze_to_tar",
"(",
"script_path",
",",
"freeze_fn",
",",
"extra_files",
"=",
"None",
")",
":",
"if",
"not",
"extra_files",
":",
"extra_files",
"=",
"[",
"]",
"freeze_dir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"try",
":",
"cmds",
"=",
"fre... | Freezes a script to a .tar or .tar.gz file
The script contains all of the files at the root of the tar
Args:
script_path: Path to python script to be frozen.
freeze_fn: Tar filename (must end in .tar or .tar.gz)
extra_files: List of paths to add to the tar (default is None)
Return... | [
"Freezes",
"a",
"script",
"to",
"a",
".",
"tar",
"or",
".",
"tar",
".",
"gz",
"file"
] | ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6 | https://github.com/bwhite/hadoopy/blob/ff39b4e6d4e6efaf1f571cf0f2c0e0d7ab28c2d6/hadoopy/_freeze.py#L191-L228 | train |
rehandalal/flask-mobility | flask_mobility/decorators.py | mobile_template | def mobile_template(template):
"""
Mark a function as mobile-ready and pass a mobile template if MOBILE.
For example::
@mobile_template('a/{mobile/}b.html')
def view(template=None):
...
if ``request.MOBILE=True`` the template will be `a/mobile/b.html`.
if ``request.MO... | python | def mobile_template(template):
"""
Mark a function as mobile-ready and pass a mobile template if MOBILE.
For example::
@mobile_template('a/{mobile/}b.html')
def view(template=None):
...
if ``request.MOBILE=True`` the template will be `a/mobile/b.html`.
if ``request.MO... | [
"def",
"mobile_template",
"(",
"template",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"ctx",
"=",
"stack",
".",
"top",
"if",
... | Mark a function as mobile-ready and pass a mobile template if MOBILE.
For example::
@mobile_template('a/{mobile/}b.html')
def view(template=None):
...
if ``request.MOBILE=True`` the template will be `a/mobile/b.html`.
if ``request.MOBILE=False`` the template will be `a/b.html... | [
"Mark",
"a",
"function",
"as",
"mobile",
"-",
"ready",
"and",
"pass",
"a",
"mobile",
"template",
"if",
"MOBILE",
"."
] | 6fff3272baf870f2267c05c611df2ba505230321 | https://github.com/rehandalal/flask-mobility/blob/6fff3272baf870f2267c05c611df2ba505230321/flask_mobility/decorators.py#L7-L37 | train |
rehandalal/flask-mobility | flask_mobility/decorators.py | mobilized | def mobilized(normal_fn):
"""
Replace a view function with a normal and mobile view.
For example::
def view():
...
@mobilized(view)
def view():
...
The second function is the mobile version of view. The original
function is overwritten, and the de... | python | def mobilized(normal_fn):
"""
Replace a view function with a normal and mobile view.
For example::
def view():
...
@mobilized(view)
def view():
...
The second function is the mobile version of view. The original
function is overwritten, and the de... | [
"def",
"mobilized",
"(",
"normal_fn",
")",
":",
"def",
"decorator",
"(",
"mobile_fn",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"mobile_fn",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"ctx",
"=",
"stack",
".",
"top",... | Replace a view function with a normal and mobile view.
For example::
def view():
...
@mobilized(view)
def view():
...
The second function is the mobile version of view. The original
function is overwritten, and the decorator will choose the correct
fu... | [
"Replace",
"a",
"view",
"function",
"with",
"a",
"normal",
"and",
"mobile",
"view",
"."
] | 6fff3272baf870f2267c05c611df2ba505230321 | https://github.com/rehandalal/flask-mobility/blob/6fff3272baf870f2267c05c611df2ba505230321/flask_mobility/decorators.py#L40-L69 | train |
achiku/jungle | jungle/rds.py | format_output | def format_output(instances, flag):
"""return formatted string per instance"""
out = []
line_format = '{0}\t{1}\t{2}\t{3}'
name_len = _get_max_name_len(instances) + 3
if flag:
line_format = '{0:<' + str(name_len+5) + '}{1:<16}{2:<65}{3:<16}'
for i in instances:
endpoint = "{0}:{... | python | def format_output(instances, flag):
"""return formatted string per instance"""
out = []
line_format = '{0}\t{1}\t{2}\t{3}'
name_len = _get_max_name_len(instances) + 3
if flag:
line_format = '{0:<' + str(name_len+5) + '}{1:<16}{2:<65}{3:<16}'
for i in instances:
endpoint = "{0}:{... | [
"def",
"format_output",
"(",
"instances",
",",
"flag",
")",
":",
"out",
"=",
"[",
"]",
"line_format",
"=",
"'{0}\\t{1}\\t{2}\\t{3}'",
"name_len",
"=",
"_get_max_name_len",
"(",
"instances",
")",
"+",
"3",
"if",
"flag",
":",
"line_format",
"=",
"'{0:<'",
"+",... | return formatted string per instance | [
"return",
"formatted",
"string",
"per",
"instance"
] | fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca | https://github.com/achiku/jungle/blob/fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca/jungle/rds.py#L6-L18 | train |
achiku/jungle | jungle/rds.py | ls | def ls(ctx, list_formatted):
"""List RDS instances"""
session = create_session(ctx.obj['AWS_PROFILE_NAME'])
rds = session.client('rds')
instances = rds.describe_db_instances()
out = format_output(instances['DBInstances'], list_formatted)
click.echo('\n'.join(out)) | python | def ls(ctx, list_formatted):
"""List RDS instances"""
session = create_session(ctx.obj['AWS_PROFILE_NAME'])
rds = session.client('rds')
instances = rds.describe_db_instances()
out = format_output(instances['DBInstances'], list_formatted)
click.echo('\n'.join(out)) | [
"def",
"ls",
"(",
"ctx",
",",
"list_formatted",
")",
":",
"session",
"=",
"create_session",
"(",
"ctx",
".",
"obj",
"[",
"'AWS_PROFILE_NAME'",
"]",
")",
"rds",
"=",
"session",
".",
"client",
"(",
"'rds'",
")",
"instances",
"=",
"rds",
".",
"describe_db_i... | List RDS instances | [
"List",
"RDS",
"instances"
] | fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca | https://github.com/achiku/jungle/blob/fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca/jungle/rds.py#L39-L46 | train |
achiku/jungle | jungle/emr.py | ls | def ls(ctx, name):
"""List EMR instances"""
session = create_session(ctx.obj['AWS_PROFILE_NAME'])
client = session.client('emr')
results = client.list_clusters(
ClusterStates=['RUNNING', 'STARTING', 'BOOTSTRAPPING', 'WAITING']
)
for cluster in results['Clusters']:
click.echo("{0... | python | def ls(ctx, name):
"""List EMR instances"""
session = create_session(ctx.obj['AWS_PROFILE_NAME'])
client = session.client('emr')
results = client.list_clusters(
ClusterStates=['RUNNING', 'STARTING', 'BOOTSTRAPPING', 'WAITING']
)
for cluster in results['Clusters']:
click.echo("{0... | [
"def",
"ls",
"(",
"ctx",
",",
"name",
")",
":",
"session",
"=",
"create_session",
"(",
"ctx",
".",
"obj",
"[",
"'AWS_PROFILE_NAME'",
"]",
")",
"client",
"=",
"session",
".",
"client",
"(",
"'emr'",
")",
"results",
"=",
"client",
".",
"list_clusters",
"... | List EMR instances | [
"List",
"EMR",
"instances"
] | fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca | https://github.com/achiku/jungle/blob/fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca/jungle/emr.py#L20-L29 | train |
achiku/jungle | jungle/emr.py | ssh | def ssh(ctx, cluster_id, key_file):
"""SSH login to EMR master node"""
session = create_session(ctx.obj['AWS_PROFILE_NAME'])
client = session.client('emr')
result = client.describe_cluster(ClusterId=cluster_id)
target_dns = result['Cluster']['MasterPublicDnsName']
ssh_options = '-o StrictHostKe... | python | def ssh(ctx, cluster_id, key_file):
"""SSH login to EMR master node"""
session = create_session(ctx.obj['AWS_PROFILE_NAME'])
client = session.client('emr')
result = client.describe_cluster(ClusterId=cluster_id)
target_dns = result['Cluster']['MasterPublicDnsName']
ssh_options = '-o StrictHostKe... | [
"def",
"ssh",
"(",
"ctx",
",",
"cluster_id",
",",
"key_file",
")",
":",
"session",
"=",
"create_session",
"(",
"ctx",
".",
"obj",
"[",
"'AWS_PROFILE_NAME'",
"]",
")",
"client",
"=",
"session",
".",
"client",
"(",
"'emr'",
")",
"result",
"=",
"client",
... | SSH login to EMR master node | [
"SSH",
"login",
"to",
"EMR",
"master",
"node"
] | fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca | https://github.com/achiku/jungle/blob/fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca/jungle/emr.py#L36-L46 | train |
achiku/jungle | jungle/emr.py | rm | def rm(ctx, cluster_id):
"""Terminate a EMR cluster"""
session = create_session(ctx.obj['AWS_PROFILE_NAME'])
client = session.client('emr')
try:
result = client.describe_cluster(ClusterId=cluster_id)
target_dns = result['Cluster']['MasterPublicDnsName']
flag = click.prompt(
... | python | def rm(ctx, cluster_id):
"""Terminate a EMR cluster"""
session = create_session(ctx.obj['AWS_PROFILE_NAME'])
client = session.client('emr')
try:
result = client.describe_cluster(ClusterId=cluster_id)
target_dns = result['Cluster']['MasterPublicDnsName']
flag = click.prompt(
... | [
"def",
"rm",
"(",
"ctx",
",",
"cluster_id",
")",
":",
"session",
"=",
"create_session",
"(",
"ctx",
".",
"obj",
"[",
"'AWS_PROFILE_NAME'",
"]",
")",
"client",
"=",
"session",
".",
"client",
"(",
"'emr'",
")",
"try",
":",
"result",
"=",
"client",
".",
... | Terminate a EMR cluster | [
"Terminate",
"a",
"EMR",
"cluster"
] | fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca | https://github.com/achiku/jungle/blob/fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca/jungle/emr.py#L52-L66 | train |
achiku/jungle | jungle/ec2.py | get_tag_value | def get_tag_value(x, key):
"""Get a value from tag"""
if x is None:
return ''
result = [y['Value'] for y in x if y['Key'] == key]
if result:
return result[0]
return '' | python | def get_tag_value(x, key):
"""Get a value from tag"""
if x is None:
return ''
result = [y['Value'] for y in x if y['Key'] == key]
if result:
return result[0]
return '' | [
"def",
"get_tag_value",
"(",
"x",
",",
"key",
")",
":",
"if",
"x",
"is",
"None",
":",
"return",
"''",
"result",
"=",
"[",
"y",
"[",
"'Value'",
"]",
"for",
"y",
"in",
"x",
"if",
"y",
"[",
"'Key'",
"]",
"==",
"key",
"]",
"if",
"result",
":",
"r... | Get a value from tag | [
"Get",
"a",
"value",
"from",
"tag"
] | fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca | https://github.com/achiku/jungle/blob/fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca/jungle/ec2.py#L43-L50 | train |
achiku/jungle | jungle/ec2.py | ls | def ls(ctx, name, list_formatted):
"""List EC2 instances"""
session = create_session(ctx.obj['AWS_PROFILE_NAME'])
ec2 = session.resource('ec2')
if name == '*':
instances = ec2.instances.filter()
else:
condition = {'Name': 'tag:Name', 'Values': [name]}
instances = ec2.instance... | python | def ls(ctx, name, list_formatted):
"""List EC2 instances"""
session = create_session(ctx.obj['AWS_PROFILE_NAME'])
ec2 = session.resource('ec2')
if name == '*':
instances = ec2.instances.filter()
else:
condition = {'Name': 'tag:Name', 'Values': [name]}
instances = ec2.instance... | [
"def",
"ls",
"(",
"ctx",
",",
"name",
",",
"list_formatted",
")",
":",
"session",
"=",
"create_session",
"(",
"ctx",
".",
"obj",
"[",
"'AWS_PROFILE_NAME'",
"]",
")",
"ec2",
"=",
"session",
".",
"resource",
"(",
"'ec2'",
")",
"if",
"name",
"==",
"'*'",
... | List EC2 instances | [
"List",
"EC2",
"instances"
] | fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca | https://github.com/achiku/jungle/blob/fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca/jungle/ec2.py#L65-L75 | train |
achiku/jungle | jungle/ec2.py | up | def up(ctx, instance_id):
"""Start EC2 instance"""
session = create_session(ctx.obj['AWS_PROFILE_NAME'])
ec2 = session.resource('ec2')
try:
instance = ec2.Instance(instance_id)
instance.start()
except botocore.exceptions.ClientError as e:
click.echo("Invalid instance ID {0} (... | python | def up(ctx, instance_id):
"""Start EC2 instance"""
session = create_session(ctx.obj['AWS_PROFILE_NAME'])
ec2 = session.resource('ec2')
try:
instance = ec2.Instance(instance_id)
instance.start()
except botocore.exceptions.ClientError as e:
click.echo("Invalid instance ID {0} (... | [
"def",
"up",
"(",
"ctx",
",",
"instance_id",
")",
":",
"session",
"=",
"create_session",
"(",
"ctx",
".",
"obj",
"[",
"'AWS_PROFILE_NAME'",
"]",
")",
"ec2",
"=",
"session",
".",
"resource",
"(",
"'ec2'",
")",
"try",
":",
"instance",
"=",
"ec2",
".",
... | Start EC2 instance | [
"Start",
"EC2",
"instance"
] | fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca | https://github.com/achiku/jungle/blob/fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca/jungle/ec2.py#L81-L90 | train |
achiku/jungle | jungle/ec2.py | create_ssh_command | def create_ssh_command(session, instance_id, instance_name, username, key_file, port, ssh_options,
use_private_ip, gateway_instance_id, gateway_username):
"""Create SSH Login command string"""
ec2 = session.resource('ec2')
if instance_id is not None:
try:
instance ... | python | def create_ssh_command(session, instance_id, instance_name, username, key_file, port, ssh_options,
use_private_ip, gateway_instance_id, gateway_username):
"""Create SSH Login command string"""
ec2 = session.resource('ec2')
if instance_id is not None:
try:
instance ... | [
"def",
"create_ssh_command",
"(",
"session",
",",
"instance_id",
",",
"instance_name",
",",
"username",
",",
"key_file",
",",
"port",
",",
"ssh_options",
",",
"use_private_ip",
",",
"gateway_instance_id",
",",
"gateway_username",
")",
":",
"ec2",
"=",
"session",
... | Create SSH Login command string | [
"Create",
"SSH",
"Login",
"command",
"string"
] | fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca | https://github.com/achiku/jungle/blob/fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca/jungle/ec2.py#L108-L169 | train |
achiku/jungle | jungle/ec2.py | ssh | def ssh(ctx, instance_id, instance_name, username, key_file, port, ssh_options, private_ip,
gateway_instance_id, gateway_username, dry_run):
"""SSH to EC2 instance"""
session = create_session(ctx.obj['AWS_PROFILE_NAME'])
if instance_id is None and instance_name is None:
click.echo(
... | python | def ssh(ctx, instance_id, instance_name, username, key_file, port, ssh_options, private_ip,
gateway_instance_id, gateway_username, dry_run):
"""SSH to EC2 instance"""
session = create_session(ctx.obj['AWS_PROFILE_NAME'])
if instance_id is None and instance_name is None:
click.echo(
... | [
"def",
"ssh",
"(",
"ctx",
",",
"instance_id",
",",
"instance_name",
",",
"username",
",",
"key_file",
",",
"port",
",",
"ssh_options",
",",
"private_ip",
",",
"gateway_instance_id",
",",
"gateway_username",
",",
"dry_run",
")",
":",
"session",
"=",
"create_ses... | SSH to EC2 instance | [
"SSH",
"to",
"EC2",
"instance"
] | fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca | https://github.com/achiku/jungle/blob/fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca/jungle/ec2.py#L191-L212 | train |
achiku/jungle | jungle/elb.py | ls | def ls(ctx, name, list_instances):
"""List ELB instances"""
session = create_session(ctx.obj['AWS_PROFILE_NAME'])
client = session.client('elb')
inst = {'LoadBalancerDescriptions': []}
if name == '*':
inst = client.describe_load_balancers()
else:
try:
inst = client.d... | python | def ls(ctx, name, list_instances):
"""List ELB instances"""
session = create_session(ctx.obj['AWS_PROFILE_NAME'])
client = session.client('elb')
inst = {'LoadBalancerDescriptions': []}
if name == '*':
inst = client.describe_load_balancers()
else:
try:
inst = client.d... | [
"def",
"ls",
"(",
"ctx",
",",
"name",
",",
"list_instances",
")",
":",
"session",
"=",
"create_session",
"(",
"ctx",
".",
"obj",
"[",
"'AWS_PROFILE_NAME'",
"]",
")",
"client",
"=",
"session",
".",
"client",
"(",
"'elb'",
")",
"inst",
"=",
"{",
"'LoadBa... | List ELB instances | [
"List",
"ELB",
"instances"
] | fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca | https://github.com/achiku/jungle/blob/fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca/jungle/elb.py#L19-L41 | train |
achiku/jungle | jungle/asg.py | ls | def ls(ctx, name, list_formatted):
"""List AutoScaling groups"""
session = create_session(ctx.obj['AWS_PROFILE_NAME'])
client = session.client('autoscaling')
if name == "*":
groups = client.describe_auto_scaling_groups()
else:
groups = client.describe_auto_scaling_groups(
... | python | def ls(ctx, name, list_formatted):
"""List AutoScaling groups"""
session = create_session(ctx.obj['AWS_PROFILE_NAME'])
client = session.client('autoscaling')
if name == "*":
groups = client.describe_auto_scaling_groups()
else:
groups = client.describe_auto_scaling_groups(
... | [
"def",
"ls",
"(",
"ctx",
",",
"name",
",",
"list_formatted",
")",
":",
"session",
"=",
"create_session",
"(",
"ctx",
".",
"obj",
"[",
"'AWS_PROFILE_NAME'",
"]",
")",
"client",
"=",
"session",
".",
"client",
"(",
"'autoscaling'",
")",
"if",
"name",
"==",
... | List AutoScaling groups | [
"List",
"AutoScaling",
"groups"
] | fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca | https://github.com/achiku/jungle/blob/fb63f845cfa9e9c0dfbabd8cfa3ebca8177a11ca/jungle/asg.py#L35-L49 | train |
wooyek/flask-social-blueprint | src/flask_social_blueprint/core.py | SocialBlueprint.authenticate | def authenticate(self, provider):
"""
Starts OAuth authorization flow, will redirect to 3rd party site.
"""
callback_url = url_for(".callback", provider=provider, _external=True)
provider = self.get_provider(provider)
session['next'] = request.args.get('next') or ''
... | python | def authenticate(self, provider):
"""
Starts OAuth authorization flow, will redirect to 3rd party site.
"""
callback_url = url_for(".callback", provider=provider, _external=True)
provider = self.get_provider(provider)
session['next'] = request.args.get('next') or ''
... | [
"def",
"authenticate",
"(",
"self",
",",
"provider",
")",
":",
"callback_url",
"=",
"url_for",
"(",
"\".callback\"",
",",
"provider",
"=",
"provider",
",",
"_external",
"=",
"True",
")",
"provider",
"=",
"self",
".",
"get_provider",
"(",
"provider",
")",
"... | Starts OAuth authorization flow, will redirect to 3rd party site. | [
"Starts",
"OAuth",
"authorization",
"flow",
"will",
"redirect",
"to",
"3rd",
"party",
"site",
"."
] | fc0ea5bc7a2efb833d78366cdaa4a1b7add807a4 | https://github.com/wooyek/flask-social-blueprint/blob/fc0ea5bc7a2efb833d78366cdaa4a1b7add807a4/src/flask_social_blueprint/core.py#L30-L37 | train |
wooyek/flask-social-blueprint | src/flask_social_blueprint/core.py | SocialBlueprint.callback | def callback(self, provider):
"""
Handles 3rd party callback and processes it's data
"""
provider = self.get_provider(provider)
try:
return provider.authorized_handler(self.login)(provider=provider)
except OAuthException as ex:
logging.error("Data:... | python | def callback(self, provider):
"""
Handles 3rd party callback and processes it's data
"""
provider = self.get_provider(provider)
try:
return provider.authorized_handler(self.login)(provider=provider)
except OAuthException as ex:
logging.error("Data:... | [
"def",
"callback",
"(",
"self",
",",
"provider",
")",
":",
"provider",
"=",
"self",
".",
"get_provider",
"(",
"provider",
")",
"try",
":",
"return",
"provider",
".",
"authorized_handler",
"(",
"self",
".",
"login",
")",
"(",
"provider",
"=",
"provider",
... | Handles 3rd party callback and processes it's data | [
"Handles",
"3rd",
"party",
"callback",
"and",
"processes",
"it",
"s",
"data"
] | fc0ea5bc7a2efb833d78366cdaa4a1b7add807a4 | https://github.com/wooyek/flask-social-blueprint/blob/fc0ea5bc7a2efb833d78366cdaa4a1b7add807a4/src/flask_social_blueprint/core.py#L39-L48 | train |
ecometrica/django-vinaigrette | vinaigrette/__init__.py | register | def register(model, fields, restrict_to=None, manager=None, properties=None, contexts=None):
"""Tell vinaigrette which fields on a Django model should be translated.
Arguments:
model -- The relevant model class
fields -- A list or tuple of field names. e.g. ['name', 'nickname']
restrict_to -- Optio... | python | def register(model, fields, restrict_to=None, manager=None, properties=None, contexts=None):
"""Tell vinaigrette which fields on a Django model should be translated.
Arguments:
model -- The relevant model class
fields -- A list or tuple of field names. e.g. ['name', 'nickname']
restrict_to -- Optio... | [
"def",
"register",
"(",
"model",
",",
"fields",
",",
"restrict_to",
"=",
"None",
",",
"manager",
"=",
"None",
",",
"properties",
"=",
"None",
",",
"contexts",
"=",
"None",
")",
":",
"if",
"not",
"contexts",
":",
"contexts",
"=",
"{",
"}",
"global",
"... | Tell vinaigrette which fields on a Django model should be translated.
Arguments:
model -- The relevant model class
fields -- A list or tuple of field names. e.g. ['name', 'nickname']
restrict_to -- Optional. A django.db.models.Q object representing the subset
of objects to collect translation s... | [
"Tell",
"vinaigrette",
"which",
"fields",
"on",
"a",
"Django",
"model",
"should",
"be",
"translated",
"."
] | abfb3396407f06150af9ea8c333afa286ad08235 | https://github.com/ecometrica/django-vinaigrette/blob/abfb3396407f06150af9ea8c333afa286ad08235/vinaigrette/__init__.py#L29-L66 | train |
MicroPyramid/django-simple-pagination | simple_pagination/utils.py | get_page_numbers | def get_page_numbers(current_page, num_pages):
"""Default callable for page listing.
Produce a Digg-style pagination.
"""
if current_page <= 2:
start_page = 1
else:
start_page = current_page - 2
if num_pages <= 4:
end_page = num_pages
else:
end_page = start_... | python | def get_page_numbers(current_page, num_pages):
"""Default callable for page listing.
Produce a Digg-style pagination.
"""
if current_page <= 2:
start_page = 1
else:
start_page = current_page - 2
if num_pages <= 4:
end_page = num_pages
else:
end_page = start_... | [
"def",
"get_page_numbers",
"(",
"current_page",
",",
"num_pages",
")",
":",
"if",
"current_page",
"<=",
"2",
":",
"start_page",
"=",
"1",
"else",
":",
"start_page",
"=",
"current_page",
"-",
"2",
"if",
"num_pages",
"<=",
"4",
":",
"end_page",
"=",
"num_pag... | Default callable for page listing.
Produce a Digg-style pagination. | [
"Default",
"callable",
"for",
"page",
"listing",
".",
"Produce",
"a",
"Digg",
"-",
"style",
"pagination",
"."
] | 8cb68b2b51b06cf8f72a13afa64564b1c49c3b41 | https://github.com/MicroPyramid/django-simple-pagination/blob/8cb68b2b51b06cf8f72a13afa64564b1c49c3b41/simple_pagination/utils.py#L42-L67 | train |
ecometrica/django-vinaigrette | vinaigrette/management/commands/makemessages.py | _get_po_paths | def _get_po_paths(locales=[]):
"""Returns paths to all relevant po files in the current project."""
basedirs = [os.path.join('conf', 'locale'), 'locale']
if os.environ.get('DJANGO_SETTINGS_MODULE'):
from django.conf import settings
basedirs.extend(settings.LOCALE_PATHS)
# Gather existin... | python | def _get_po_paths(locales=[]):
"""Returns paths to all relevant po files in the current project."""
basedirs = [os.path.join('conf', 'locale'), 'locale']
if os.environ.get('DJANGO_SETTINGS_MODULE'):
from django.conf import settings
basedirs.extend(settings.LOCALE_PATHS)
# Gather existin... | [
"def",
"_get_po_paths",
"(",
"locales",
"=",
"[",
"]",
")",
":",
"basedirs",
"=",
"[",
"os",
".",
"path",
".",
"join",
"(",
"'conf'",
",",
"'locale'",
")",
",",
"'locale'",
"]",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"'DJANGO_SETTINGS_MODULE'",
... | Returns paths to all relevant po files in the current project. | [
"Returns",
"paths",
"to",
"all",
"relevant",
"po",
"files",
"in",
"the",
"current",
"project",
"."
] | abfb3396407f06150af9ea8c333afa286ad08235 | https://github.com/ecometrica/django-vinaigrette/blob/abfb3396407f06150af9ea8c333afa286ad08235/vinaigrette/management/commands/makemessages.py#L14-L35 | train |
MicroPyramid/django-simple-pagination | simple_pagination/templatetags/paginate.py | show_pageitems | def show_pageitems(_, token):
"""Show page items.
Usage:
.. code-block:: html+django
{% show_pageitems per_page %}
"""
# Validate args.
if len(token.contents.split()) != 1:
msg = '%r tag takes no arguments' % token.contents.split()[0]
raise template.TemplateSyntaxErro... | python | def show_pageitems(_, token):
"""Show page items.
Usage:
.. code-block:: html+django
{% show_pageitems per_page %}
"""
# Validate args.
if len(token.contents.split()) != 1:
msg = '%r tag takes no arguments' % token.contents.split()[0]
raise template.TemplateSyntaxErro... | [
"def",
"show_pageitems",
"(",
"_",
",",
"token",
")",
":",
"if",
"len",
"(",
"token",
".",
"contents",
".",
"split",
"(",
")",
")",
"!=",
"1",
":",
"msg",
"=",
"'%r tag takes no arguments'",
"%",
"token",
".",
"contents",
".",
"split",
"(",
")",
"[",... | Show page items.
Usage:
.. code-block:: html+django
{% show_pageitems per_page %} | [
"Show",
"page",
"items",
"."
] | 8cb68b2b51b06cf8f72a13afa64564b1c49c3b41 | https://github.com/MicroPyramid/django-simple-pagination/blob/8cb68b2b51b06cf8f72a13afa64564b1c49c3b41/simple_pagination/templatetags/paginate.py#L359-L374 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/errors.py | user_error | def user_error(status_code, title, detail, pointer):
"""Create and return a general user error response that is jsonapi compliant.
Required args:
status_code: The HTTP status code associated with the problem.
title: A short summary of the problem.
detail: An explanation specific to the ... | python | def user_error(status_code, title, detail, pointer):
"""Create and return a general user error response that is jsonapi compliant.
Required args:
status_code: The HTTP status code associated with the problem.
title: A short summary of the problem.
detail: An explanation specific to the ... | [
"def",
"user_error",
"(",
"status_code",
",",
"title",
",",
"detail",
",",
"pointer",
")",
":",
"response",
"=",
"{",
"'errors'",
":",
"[",
"{",
"'status'",
":",
"status_code",
",",
"'source'",
":",
"{",
"'pointer'",
":",
"'{0}'",
".",
"format",
"(",
"... | Create and return a general user error response that is jsonapi compliant.
Required args:
status_code: The HTTP status code associated with the problem.
title: A short summary of the problem.
detail: An explanation specific to the occurence of the problem.
pointer: The request path ... | [
"Create",
"and",
"return",
"a",
"general",
"user",
"error",
"response",
"that",
"is",
"jsonapi",
"compliant",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/errors.py#L146-L169 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/flaskext.py | override | def override(original, results):
"""
If a receiver to a signal returns a value, we override the original value
with the last returned value.
:param original: The original value
:param results: The results from the signal
"""
overrides = [v for fn, v in results if v is not None]
if len(o... | python | def override(original, results):
"""
If a receiver to a signal returns a value, we override the original value
with the last returned value.
:param original: The original value
:param results: The results from the signal
"""
overrides = [v for fn, v in results if v is not None]
if len(o... | [
"def",
"override",
"(",
"original",
",",
"results",
")",
":",
"overrides",
"=",
"[",
"v",
"for",
"fn",
",",
"v",
"in",
"results",
"if",
"v",
"is",
"not",
"None",
"]",
"if",
"len",
"(",
"overrides",
")",
"==",
"0",
":",
"return",
"original",
"return... | If a receiver to a signal returns a value, we override the original value
with the last returned value.
:param original: The original value
:param results: The results from the signal | [
"If",
"a",
"receiver",
"to",
"a",
"signal",
"returns",
"a",
"value",
"we",
"override",
"the",
"original",
"value",
"with",
"the",
"last",
"returned",
"value",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/flaskext.py#L49-L60 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/flaskext.py | JSONAPIEncoder.default | def default(self, value):
"""
Handle UUID, datetime, and callables.
:param value: Value to encode
"""
if isinstance(value, uuid.UUID):
return str(value)
elif isinstance(value, datetime.datetime):
return value.isoformat()
elif callable(valu... | python | def default(self, value):
"""
Handle UUID, datetime, and callables.
:param value: Value to encode
"""
if isinstance(value, uuid.UUID):
return str(value)
elif isinstance(value, datetime.datetime):
return value.isoformat()
elif callable(valu... | [
"def",
"default",
"(",
"self",
",",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"uuid",
".",
"UUID",
")",
":",
"return",
"str",
"(",
"value",
")",
"elif",
"isinstance",
"(",
"value",
",",
"datetime",
".",
"datetime",
")",
":",
"return",... | Handle UUID, datetime, and callables.
:param value: Value to encode | [
"Handle",
"UUID",
"datetime",
"and",
"callables",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/flaskext.py#L24-L36 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/flaskext.py | FlaskJSONAPI.init_app | def init_app(self, app, sqla, namespace='api', route_prefix='/api'):
"""
Initialize the adapter if it hasn't already been initialized.
:param app: Flask application
:param sqla: Flask-SQLAlchemy instance
:param namespace: Prefixes all generated routes
:param route_prefix... | python | def init_app(self, app, sqla, namespace='api', route_prefix='/api'):
"""
Initialize the adapter if it hasn't already been initialized.
:param app: Flask application
:param sqla: Flask-SQLAlchemy instance
:param namespace: Prefixes all generated routes
:param route_prefix... | [
"def",
"init_app",
"(",
"self",
",",
"app",
",",
"sqla",
",",
"namespace",
"=",
"'api'",
",",
"route_prefix",
"=",
"'/api'",
")",
":",
"self",
".",
"app",
"=",
"app",
"self",
".",
"sqla",
"=",
"sqla",
"self",
".",
"_setup_adapter",
"(",
"namespace",
... | Initialize the adapter if it hasn't already been initialized.
:param app: Flask application
:param sqla: Flask-SQLAlchemy instance
:param namespace: Prefixes all generated routes
:param route_prefix: The base path for the generated routes | [
"Initialize",
"the",
"adapter",
"if",
"it",
"hasn",
"t",
"already",
"been",
"initialized",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/flaskext.py#L106-L118 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/flaskext.py | FlaskJSONAPI.wrap_handler | def wrap_handler(self, api_types, methods, endpoints):
"""
Allow for a handler to be wrapped in a chain.
:param api_types: Types to wrap handlers for
:param methods: Methods to wrap handlers for
:param endpoints: Endpoints to wrap handlers for
"""
def wrapper(fn... | python | def wrap_handler(self, api_types, methods, endpoints):
"""
Allow for a handler to be wrapped in a chain.
:param api_types: Types to wrap handlers for
:param methods: Methods to wrap handlers for
:param endpoints: Endpoints to wrap handlers for
"""
def wrapper(fn... | [
"def",
"wrap_handler",
"(",
"self",
",",
"api_types",
",",
"methods",
",",
"endpoints",
")",
":",
"def",
"wrapper",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"return",
"fn"... | Allow for a handler to be wrapped in a chain.
:param api_types: Types to wrap handlers for
:param methods: Methods to wrap handlers for
:param endpoints: Endpoints to wrap handlers for | [
"Allow",
"for",
"a",
"handler",
"to",
"be",
"wrapped",
"in",
"a",
"chain",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/flaskext.py#L120-L142 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/flaskext.py | FlaskJSONAPI._call_next | def _call_next(self, handler_chain):
"""
Generates an express-like chain for handling requests.
:param handler_chain: The current chain of handlers
"""
def wrapped(*args, **kwargs):
if len(handler_chain) == 1:
return handler_chain[0](*args, **kwargs)... | python | def _call_next(self, handler_chain):
"""
Generates an express-like chain for handling requests.
:param handler_chain: The current chain of handlers
"""
def wrapped(*args, **kwargs):
if len(handler_chain) == 1:
return handler_chain[0](*args, **kwargs)... | [
"def",
"_call_next",
"(",
"self",
",",
"handler_chain",
")",
":",
"def",
"wrapped",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"len",
"(",
"handler_chain",
")",
"==",
"1",
":",
"return",
"handler_chain",
"[",
"0",
"]",
"(",
"*",
"args",
... | Generates an express-like chain for handling requests.
:param handler_chain: The current chain of handlers | [
"Generates",
"an",
"express",
"-",
"like",
"chain",
"for",
"handling",
"requests",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/flaskext.py#L144-L158 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/flaskext.py | FlaskJSONAPI._setup_adapter | def _setup_adapter(self, namespace, route_prefix):
"""
Initialize the serializer and loop through the views to generate them.
:param namespace: Prefix for generated endpoints
:param route_prefix: Prefix for route patterns
"""
self.serializer = JSONAPI(
self.s... | python | def _setup_adapter(self, namespace, route_prefix):
"""
Initialize the serializer and loop through the views to generate them.
:param namespace: Prefix for generated endpoints
:param route_prefix: Prefix for route patterns
"""
self.serializer = JSONAPI(
self.s... | [
"def",
"_setup_adapter",
"(",
"self",
",",
"namespace",
",",
"route_prefix",
")",
":",
"self",
".",
"serializer",
"=",
"JSONAPI",
"(",
"self",
".",
"sqla",
".",
"Model",
",",
"prefix",
"=",
"'{}://{}{}'",
".",
"format",
"(",
"self",
".",
"app",
".",
"c... | Initialize the serializer and loop through the views to generate them.
:param namespace: Prefix for generated endpoints
:param route_prefix: Prefix for route patterns | [
"Initialize",
"the",
"serializer",
"and",
"loop",
"through",
"the",
"views",
"to",
"generate",
"them",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/flaskext.py#L160-L181 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/flaskext.py | FlaskJSONAPI._generate_view | def _generate_view(self, method, endpoint):
"""
Generate a view for the specified method and endpoint.
:param method: HTTP Method
:param endpoint: Pattern
"""
def new_view(**kwargs):
if method == Method.GET:
data = request.args
el... | python | def _generate_view(self, method, endpoint):
"""
Generate a view for the specified method and endpoint.
:param method: HTTP Method
:param endpoint: Pattern
"""
def new_view(**kwargs):
if method == Method.GET:
data = request.args
el... | [
"def",
"_generate_view",
"(",
"self",
",",
"method",
",",
"endpoint",
")",
":",
"def",
"new_view",
"(",
"**",
"kwargs",
")",
":",
"if",
"method",
"==",
"Method",
".",
"GET",
":",
"data",
"=",
"request",
".",
"args",
"else",
":",
"content_length",
"=",
... | Generate a view for the specified method and endpoint.
:param method: HTTP Method
:param endpoint: Pattern | [
"Generate",
"a",
"view",
"for",
"the",
"specified",
"method",
"and",
"endpoint",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/flaskext.py#L183-L251 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/declarative/serializer.py | JSONAPISerializer._render_resource | def _render_resource(self, resource):
"""Renders a resource's top level members based on json-api spec.
Top level members include:
'id', 'type', 'attributes', 'relationships'
"""
if not resource:
return None
# Must not render a resource that has same name... | python | def _render_resource(self, resource):
"""Renders a resource's top level members based on json-api spec.
Top level members include:
'id', 'type', 'attributes', 'relationships'
"""
if not resource:
return None
# Must not render a resource that has same name... | [
"def",
"_render_resource",
"(",
"self",
",",
"resource",
")",
":",
"if",
"not",
"resource",
":",
"return",
"None",
"if",
"not",
"isinstance",
"(",
"resource",
",",
"self",
".",
"model",
")",
":",
"raise",
"TypeError",
"(",
"'Resource(s) type must be the same a... | Renders a resource's top level members based on json-api spec.
Top level members include:
'id', 'type', 'attributes', 'relationships' | [
"Renders",
"a",
"resource",
"s",
"top",
"level",
"members",
"based",
"on",
"json",
"-",
"api",
"spec",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/declarative/serializer.py#L45-L68 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/declarative/serializer.py | JSONAPISerializer._render_attributes | def _render_attributes(self, resource):
"""Render the resources's attributes."""
attributes = {}
attrs_to_ignore = set()
for key, relationship in resource.__mapper__.relationships.items():
attrs_to_ignore.update(set(
[column.name for column in relationship.lo... | python | def _render_attributes(self, resource):
"""Render the resources's attributes."""
attributes = {}
attrs_to_ignore = set()
for key, relationship in resource.__mapper__.relationships.items():
attrs_to_ignore.update(set(
[column.name for column in relationship.lo... | [
"def",
"_render_attributes",
"(",
"self",
",",
"resource",
")",
":",
"attributes",
"=",
"{",
"}",
"attrs_to_ignore",
"=",
"set",
"(",
")",
"for",
"key",
",",
"relationship",
"in",
"resource",
".",
"__mapper__",
".",
"relationships",
".",
"items",
"(",
")",... | Render the resources's attributes. | [
"Render",
"the",
"resources",
"s",
"attributes",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/declarative/serializer.py#L70-L101 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/declarative/serializer.py | JSONAPISerializer._render_relationships | def _render_relationships(self, resource):
"""Render the resource's relationships."""
relationships = {}
related_models = resource.__mapper__.relationships.keys()
primary_key_val = getattr(resource, self.primary_key)
if self.dasherize:
mapped_relationships = {
... | python | def _render_relationships(self, resource):
"""Render the resource's relationships."""
relationships = {}
related_models = resource.__mapper__.relationships.keys()
primary_key_val = getattr(resource, self.primary_key)
if self.dasherize:
mapped_relationships = {
... | [
"def",
"_render_relationships",
"(",
"self",
",",
"resource",
")",
":",
"relationships",
"=",
"{",
"}",
"related_models",
"=",
"resource",
".",
"__mapper__",
".",
"relationships",
".",
"keys",
"(",
")",
"primary_key_val",
"=",
"getattr",
"(",
"resource",
",",
... | Render the resource's relationships. | [
"Render",
"the",
"resource",
"s",
"relationships",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/declarative/serializer.py#L103-L128 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/serializer.py | attr_descriptor | def attr_descriptor(action, *names):
"""
Wrap a function that allows for getting or setting of an attribute. This
allows for specific handling of an attribute when it comes to serializing
and deserializing.
:param action: The AttributeActions that this descriptor performs
:param names: A list ... | python | def attr_descriptor(action, *names):
"""
Wrap a function that allows for getting or setting of an attribute. This
allows for specific handling of an attribute when it comes to serializing
and deserializing.
:param action: The AttributeActions that this descriptor performs
:param names: A list ... | [
"def",
"attr_descriptor",
"(",
"action",
",",
"*",
"names",
")",
":",
"if",
"isinstance",
"(",
"action",
",",
"AttributeActions",
")",
":",
"action",
"=",
"[",
"action",
"]",
"def",
"wrapped",
"(",
"fn",
")",
":",
"if",
"not",
"hasattr",
"(",
"fn",
"... | Wrap a function that allows for getting or setting of an attribute. This
allows for specific handling of an attribute when it comes to serializing
and deserializing.
:param action: The AttributeActions that this descriptor performs
:param names: A list of names of the attributes this references | [
"Wrap",
"a",
"function",
"that",
"allows",
"for",
"getting",
"or",
"setting",
"of",
"an",
"attribute",
".",
"This",
"allows",
"for",
"specific",
"handling",
"of",
"an",
"attribute",
"when",
"it",
"comes",
"to",
"serializing",
"and",
"deserializing",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/serializer.py#L65-L85 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/serializer.py | relationship_descriptor | def relationship_descriptor(action, *names):
"""
Wrap a function for modification of a relationship. This allows for
specific handling for serialization and deserialization.
:param action: The RelationshipActions that this descriptor performs
:param names: A list of names of the relationships this... | python | def relationship_descriptor(action, *names):
"""
Wrap a function for modification of a relationship. This allows for
specific handling for serialization and deserialization.
:param action: The RelationshipActions that this descriptor performs
:param names: A list of names of the relationships this... | [
"def",
"relationship_descriptor",
"(",
"action",
",",
"*",
"names",
")",
":",
"if",
"isinstance",
"(",
"action",
",",
"RelationshipActions",
")",
":",
"action",
"=",
"[",
"action",
"]",
"def",
"wrapped",
"(",
"fn",
")",
":",
"if",
"not",
"hasattr",
"(",
... | Wrap a function for modification of a relationship. This allows for
specific handling for serialization and deserialization.
:param action: The RelationshipActions that this descriptor performs
:param names: A list of names of the relationships this references | [
"Wrap",
"a",
"function",
"for",
"modification",
"of",
"a",
"relationship",
".",
"This",
"allows",
"for",
"specific",
"handling",
"for",
"serialization",
"and",
"deserialization",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/serializer.py#L88-L107 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/serializer.py | check_permission | def check_permission(instance, field, permission):
"""
Check a permission for a given instance or field. Raises an error if
denied.
:param instance: The instance to check
:param field: The field name to check or None for instance
:param permission: The permission to check
"""
if not ge... | python | def check_permission(instance, field, permission):
"""
Check a permission for a given instance or field. Raises an error if
denied.
:param instance: The instance to check
:param field: The field name to check or None for instance
:param permission: The permission to check
"""
if not ge... | [
"def",
"check_permission",
"(",
"instance",
",",
"field",
",",
"permission",
")",
":",
"if",
"not",
"get_permission_test",
"(",
"instance",
",",
"field",
",",
"permission",
")",
"(",
"instance",
")",
":",
"raise",
"PermissionDeniedError",
"(",
"permission",
",... | Check a permission for a given instance or field. Raises an error if
denied.
:param instance: The instance to check
:param field: The field name to check or None for instance
:param permission: The permission to check | [
"Check",
"a",
"permission",
"for",
"a",
"given",
"instance",
"or",
"field",
".",
"Raises",
"an",
"error",
"if",
"denied",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/serializer.py#L170-L180 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/serializer.py | get_attr_desc | def get_attr_desc(instance, attribute, action):
"""
Fetch the appropriate descriptor for the attribute.
:param instance: Model instance
:param attribute: Name of the attribute
:param action: AttributeAction
"""
descs = instance.__jsonapi_attribute_descriptors__.get(attribute, {})
if act... | python | def get_attr_desc(instance, attribute, action):
"""
Fetch the appropriate descriptor for the attribute.
:param instance: Model instance
:param attribute: Name of the attribute
:param action: AttributeAction
"""
descs = instance.__jsonapi_attribute_descriptors__.get(attribute, {})
if act... | [
"def",
"get_attr_desc",
"(",
"instance",
",",
"attribute",
",",
"action",
")",
":",
"descs",
"=",
"instance",
".",
"__jsonapi_attribute_descriptors__",
".",
"get",
"(",
"attribute",
",",
"{",
"}",
")",
"if",
"action",
"==",
"AttributeActions",
".",
"GET",
":... | Fetch the appropriate descriptor for the attribute.
:param instance: Model instance
:param attribute: Name of the attribute
:param action: AttributeAction | [
"Fetch",
"the",
"appropriate",
"descriptor",
"for",
"the",
"attribute",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/serializer.py#L183-L196 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/serializer.py | get_rel_desc | def get_rel_desc(instance, key, action):
"""
Fetch the appropriate descriptor for the relationship.
:param instance: Model instance
:param key: Name of the relationship
:param action: RelationshipAction
"""
descs = instance.__jsonapi_rel_desc__.get(key, {})
if action == RelationshipActi... | python | def get_rel_desc(instance, key, action):
"""
Fetch the appropriate descriptor for the relationship.
:param instance: Model instance
:param key: Name of the relationship
:param action: RelationshipAction
"""
descs = instance.__jsonapi_rel_desc__.get(key, {})
if action == RelationshipActi... | [
"def",
"get_rel_desc",
"(",
"instance",
",",
"key",
",",
"action",
")",
":",
"descs",
"=",
"instance",
".",
"__jsonapi_rel_desc__",
".",
"get",
"(",
"key",
",",
"{",
"}",
")",
"if",
"action",
"==",
"RelationshipActions",
".",
"GET",
":",
"check_permission"... | Fetch the appropriate descriptor for the relationship.
:param instance: Model instance
:param key: Name of the relationship
:param action: RelationshipAction | [
"Fetch",
"the",
"appropriate",
"descriptor",
"for",
"the",
"relationship",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/serializer.py#L199-L219 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/serializer.py | JSONAPI._check_json_data | def _check_json_data(self, json_data):
"""
Ensure that the request body is both a hash and has a data key.
:param json_data: The json data provided with the request
"""
if not isinstance(json_data, dict):
raise BadRequestError('Request body should be a JSON hash')
... | python | def _check_json_data(self, json_data):
"""
Ensure that the request body is both a hash and has a data key.
:param json_data: The json data provided with the request
"""
if not isinstance(json_data, dict):
raise BadRequestError('Request body should be a JSON hash')
... | [
"def",
"_check_json_data",
"(",
"self",
",",
"json_data",
")",
":",
"if",
"not",
"isinstance",
"(",
"json_data",
",",
"dict",
")",
":",
"raise",
"BadRequestError",
"(",
"'Request body should be a JSON hash'",
")",
"if",
"'data'",
"not",
"in",
"json_data",
".",
... | Ensure that the request body is both a hash and has a data key.
:param json_data: The json data provided with the request | [
"Ensure",
"that",
"the",
"request",
"body",
"is",
"both",
"a",
"hash",
"and",
"has",
"a",
"data",
"key",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/serializer.py#L321-L330 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/serializer.py | JSONAPI._fetch_resource | def _fetch_resource(self, session, api_type, obj_id, permission):
"""
Fetch a resource by type and id, also doing a permission check.
:param session: SQLAlchemy session
:param api_type: The type
:param obj_id: ID for the resource
:param permission: Permission to check
... | python | def _fetch_resource(self, session, api_type, obj_id, permission):
"""
Fetch a resource by type and id, also doing a permission check.
:param session: SQLAlchemy session
:param api_type: The type
:param obj_id: ID for the resource
:param permission: Permission to check
... | [
"def",
"_fetch_resource",
"(",
"self",
",",
"session",
",",
"api_type",
",",
"obj_id",
",",
"permission",
")",
":",
"if",
"api_type",
"not",
"in",
"self",
".",
"models",
".",
"keys",
"(",
")",
":",
"raise",
"ResourceTypeNotFoundError",
"(",
"api_type",
")"... | Fetch a resource by type and id, also doing a permission check.
:param session: SQLAlchemy session
:param api_type: The type
:param obj_id: ID for the resource
:param permission: Permission to check | [
"Fetch",
"a",
"resource",
"by",
"type",
"and",
"id",
"also",
"doing",
"a",
"permission",
"check",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/serializer.py#L332-L347 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/serializer.py | JSONAPI._render_short_instance | def _render_short_instance(self, instance):
"""
For those very short versions of resources, we have this.
:param instance: The instance to render
"""
check_permission(instance, None, Permissions.VIEW)
return {'type': instance.__jsonapi_type__, 'id': instance.id} | python | def _render_short_instance(self, instance):
"""
For those very short versions of resources, we have this.
:param instance: The instance to render
"""
check_permission(instance, None, Permissions.VIEW)
return {'type': instance.__jsonapi_type__, 'id': instance.id} | [
"def",
"_render_short_instance",
"(",
"self",
",",
"instance",
")",
":",
"check_permission",
"(",
"instance",
",",
"None",
",",
"Permissions",
".",
"VIEW",
")",
"return",
"{",
"'type'",
":",
"instance",
".",
"__jsonapi_type__",
",",
"'id'",
":",
"instance",
... | For those very short versions of resources, we have this.
:param instance: The instance to render | [
"For",
"those",
"very",
"short",
"versions",
"of",
"resources",
"we",
"have",
"this",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/serializer.py#L349-L356 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/serializer.py | JSONAPI._check_instance_relationships_for_delete | def _check_instance_relationships_for_delete(self, instance):
"""
Ensure we are authorized to delete this and all cascaded resources.
:param instance: The instance to check the relationships of.
"""
check_permission(instance, None, Permissions.DELETE)
for rel_key, rel in... | python | def _check_instance_relationships_for_delete(self, instance):
"""
Ensure we are authorized to delete this and all cascaded resources.
:param instance: The instance to check the relationships of.
"""
check_permission(instance, None, Permissions.DELETE)
for rel_key, rel in... | [
"def",
"_check_instance_relationships_for_delete",
"(",
"self",
",",
"instance",
")",
":",
"check_permission",
"(",
"instance",
",",
"None",
",",
"Permissions",
".",
"DELETE",
")",
"for",
"rel_key",
",",
"rel",
"in",
"instance",
".",
"__mapper__",
".",
"relation... | Ensure we are authorized to delete this and all cascaded resources.
:param instance: The instance to check the relationships of. | [
"Ensure",
"we",
"are",
"authorized",
"to",
"delete",
"this",
"and",
"all",
"cascaded",
"resources",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/serializer.py#L462-L479 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/serializer.py | JSONAPI._parse_fields | def _parse_fields(self, query):
"""
Parse the querystring args for fields.
:param query: Dict of query args
"""
field_args = {
k: v
for k, v in query.items() if k.startswith('fields[')
}
fields = {}
for k, v in field_args.items()... | python | def _parse_fields(self, query):
"""
Parse the querystring args for fields.
:param query: Dict of query args
"""
field_args = {
k: v
for k, v in query.items() if k.startswith('fields[')
}
fields = {}
for k, v in field_args.items()... | [
"def",
"_parse_fields",
"(",
"self",
",",
"query",
")",
":",
"field_args",
"=",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"query",
".",
"items",
"(",
")",
"if",
"k",
".",
"startswith",
"(",
"'fields['",
")",
"}",
"fields",
"=",
"{",
"}",
... | Parse the querystring args for fields.
:param query: Dict of query args | [
"Parse",
"the",
"querystring",
"args",
"for",
"fields",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/serializer.py#L481-L497 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/serializer.py | JSONAPI._parse_include | def _parse_include(self, include):
"""
Parse the querystring args or parent includes for includes.
:param include: Dict of query args or includes
"""
ret = {}
for item in include:
if '.' in item:
local, remote = item.split('.', 1)
... | python | def _parse_include(self, include):
"""
Parse the querystring args or parent includes for includes.
:param include: Dict of query args or includes
"""
ret = {}
for item in include:
if '.' in item:
local, remote = item.split('.', 1)
... | [
"def",
"_parse_include",
"(",
"self",
",",
"include",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"item",
"in",
"include",
":",
"if",
"'.'",
"in",
"item",
":",
"local",
",",
"remote",
"=",
"item",
".",
"split",
"(",
"'.'",
",",
"1",
")",
"else",
":",
... | Parse the querystring args or parent includes for includes.
:param include: Dict of query args or includes | [
"Parse",
"the",
"querystring",
"args",
"or",
"parent",
"includes",
"for",
"includes",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/serializer.py#L499-L517 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/serializer.py | JSONAPI._parse_page | def _parse_page(self, query):
"""
Parse the querystring args for pagination.
:param query: Dict of query args
"""
args = {k[5:-1]: v for k, v in query.items() if k.startswith('page[')}
if {'number', 'size'} == set(args.keys()):
if not args['number'].isdecima... | python | def _parse_page(self, query):
"""
Parse the querystring args for pagination.
:param query: Dict of query args
"""
args = {k[5:-1]: v for k, v in query.items() if k.startswith('page[')}
if {'number', 'size'} == set(args.keys()):
if not args['number'].isdecima... | [
"def",
"_parse_page",
"(",
"self",
",",
"query",
")",
":",
"args",
"=",
"{",
"k",
"[",
"5",
":",
"-",
"1",
"]",
":",
"v",
"for",
"k",
",",
"v",
"in",
"query",
".",
"items",
"(",
")",
"if",
"k",
".",
"startswith",
"(",
"'page['",
")",
"}",
"... | Parse the querystring args for pagination.
:param query: Dict of query args | [
"Parse",
"the",
"querystring",
"args",
"for",
"pagination",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/serializer.py#L519-L546 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/serializer.py | JSONAPI.delete_relationship | def delete_relationship(self, session, data, api_type, obj_id, rel_key):
"""
Delete a resource or multiple resources from a to-many relationship.
:param session: SQLAlchemy session
:param data: JSON data provided with the request
:param api_type: Type of the resource
:pa... | python | def delete_relationship(self, session, data, api_type, obj_id, rel_key):
"""
Delete a resource or multiple resources from a to-many relationship.
:param session: SQLAlchemy session
:param data: JSON data provided with the request
:param api_type: Type of the resource
:pa... | [
"def",
"delete_relationship",
"(",
"self",
",",
"session",
",",
"data",
",",
"api_type",
",",
"obj_id",
",",
"rel_key",
")",
":",
"model",
"=",
"self",
".",
"_fetch_model",
"(",
"api_type",
")",
"resource",
"=",
"self",
".",
"_fetch_resource",
"(",
"sessio... | Delete a resource or multiple resources from a to-many relationship.
:param session: SQLAlchemy session
:param data: JSON data provided with the request
:param api_type: Type of the resource
:param obj_id: ID of the resource
:param rel_key: Key of the relationship to fetch | [
"Delete",
"a",
"resource",
"or",
"multiple",
"resources",
"from",
"a",
"to",
"-",
"many",
"relationship",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/serializer.py#L548-L604 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/serializer.py | JSONAPI.get_collection | def get_collection(self, session, query, api_key):
"""
Fetch a collection of resources of a specified type.
:param session: SQLAlchemy session
:param query: Dict of query args
:param api_type: The type of the model
"""
model = self._fetch_model(api_key)
i... | python | def get_collection(self, session, query, api_key):
"""
Fetch a collection of resources of a specified type.
:param session: SQLAlchemy session
:param query: Dict of query args
:param api_type: The type of the model
"""
model = self._fetch_model(api_key)
i... | [
"def",
"get_collection",
"(",
"self",
",",
"session",
",",
"query",
",",
"api_key",
")",
":",
"model",
"=",
"self",
".",
"_fetch_model",
"(",
"api_key",
")",
"include",
"=",
"self",
".",
"_parse_include",
"(",
"query",
".",
"get",
"(",
"'include'",
",",
... | Fetch a collection of resources of a specified type.
:param session: SQLAlchemy session
:param query: Dict of query args
:param api_type: The type of the model | [
"Fetch",
"a",
"collection",
"of",
"resources",
"of",
"a",
"specified",
"type",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/serializer.py#L627-L690 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/serializer.py | JSONAPI.get_relationship | def get_relationship(self, session, query, api_type, obj_id, rel_key):
"""
Fetch a collection of related resource types and ids.
:param session: SQLAlchemy session
:param query: Dict of query args
:param api_type: Type of the resource
:param obj_id: ID of the resource
... | python | def get_relationship(self, session, query, api_type, obj_id, rel_key):
"""
Fetch a collection of related resource types and ids.
:param session: SQLAlchemy session
:param query: Dict of query args
:param api_type: Type of the resource
:param obj_id: ID of the resource
... | [
"def",
"get_relationship",
"(",
"self",
",",
"session",
",",
"query",
",",
"api_type",
",",
"obj_id",
",",
"rel_key",
")",
":",
"resource",
"=",
"self",
".",
"_fetch_resource",
"(",
"session",
",",
"api_type",
",",
"obj_id",
",",
"Permissions",
".",
"VIEW"... | Fetch a collection of related resource types and ids.
:param session: SQLAlchemy session
:param query: Dict of query args
:param api_type: Type of the resource
:param obj_id: ID of the resource
:param rel_key: Key of the relationship to fetch | [
"Fetch",
"a",
"collection",
"of",
"related",
"resource",
"types",
"and",
"ids",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/serializer.py#L758-L798 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/serializer.py | JSONAPI.patch_relationship | def patch_relationship(self, session, json_data, api_type, obj_id,
rel_key):
"""
Replacement of relationship values.
:param session: SQLAlchemy session
:param json_data: Request JSON Data
:param api_type: Type of the resource
:param obj_id: ID ... | python | def patch_relationship(self, session, json_data, api_type, obj_id,
rel_key):
"""
Replacement of relationship values.
:param session: SQLAlchemy session
:param json_data: Request JSON Data
:param api_type: Type of the resource
:param obj_id: ID ... | [
"def",
"patch_relationship",
"(",
"self",
",",
"session",
",",
"json_data",
",",
"api_type",
",",
"obj_id",
",",
"rel_key",
")",
":",
"model",
"=",
"self",
".",
"_fetch_model",
"(",
"api_type",
")",
"resource",
"=",
"self",
".",
"_fetch_resource",
"(",
"se... | Replacement of relationship values.
:param session: SQLAlchemy session
:param json_data: Request JSON Data
:param api_type: Type of the resource
:param obj_id: ID of the resource
:param rel_key: Key of the relationship to fetch | [
"Replacement",
"of",
"relationship",
"values",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/serializer.py#L800-L880 | train |
ColtonProvias/sqlalchemy-jsonapi | sqlalchemy_jsonapi/serializer.py | JSONAPI.post_relationship | def post_relationship(self, session, json_data, api_type, obj_id, rel_key):
"""
Append to a relationship.
:param session: SQLAlchemy session
:param json_data: Request JSON Data
:param api_type: Type of the resource
:param obj_id: ID of the resource
:param rel_key... | python | def post_relationship(self, session, json_data, api_type, obj_id, rel_key):
"""
Append to a relationship.
:param session: SQLAlchemy session
:param json_data: Request JSON Data
:param api_type: Type of the resource
:param obj_id: ID of the resource
:param rel_key... | [
"def",
"post_relationship",
"(",
"self",
",",
"session",
",",
"json_data",
",",
"api_type",
",",
"obj_id",
",",
"rel_key",
")",
":",
"model",
"=",
"self",
".",
"_fetch_model",
"(",
"api_type",
")",
"resource",
"=",
"self",
".",
"_fetch_resource",
"(",
"ses... | Append to a relationship.
:param session: SQLAlchemy session
:param json_data: Request JSON Data
:param api_type: Type of the resource
:param obj_id: ID of the resource
:param rel_key: Key of the relationship to fetch | [
"Append",
"to",
"a",
"relationship",
"."
] | 40f8b5970d44935b27091c2bf3224482d23311bb | https://github.com/ColtonProvias/sqlalchemy-jsonapi/blob/40f8b5970d44935b27091c2bf3224482d23311bb/sqlalchemy_jsonapi/serializer.py#L1107-L1170 | train |
MisterWil/abodepy | abodepy/helpers/timeline.py | map_event_code | def map_event_code(event_code):
"""Map a specific event_code to an event group."""
event_code = int(event_code)
# Honestly, these are just guessing based on the below event list.
# It could be wrong, I have no idea.
if 1100 <= event_code <= 1199:
return ALARM_GROUP
elif 3100 <= event_c... | python | def map_event_code(event_code):
"""Map a specific event_code to an event group."""
event_code = int(event_code)
# Honestly, these are just guessing based on the below event list.
# It could be wrong, I have no idea.
if 1100 <= event_code <= 1199:
return ALARM_GROUP
elif 3100 <= event_c... | [
"def",
"map_event_code",
"(",
"event_code",
")",
":",
"event_code",
"=",
"int",
"(",
"event_code",
")",
"if",
"1100",
"<=",
"event_code",
"<=",
"1199",
":",
"return",
"ALARM_GROUP",
"elif",
"3100",
"<=",
"event_code",
"<=",
"3199",
":",
"return",
"ALARM_END_... | Map a specific event_code to an event group. | [
"Map",
"a",
"specific",
"event_code",
"to",
"an",
"event",
"group",
"."
] | 6f84bb428fd1da98855f55083cd427bebbcc57ae | https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/helpers/timeline.py#L23-L59 | train |
MisterWil/abodepy | abodepy/automation.py | AbodeAutomation.set_active | def set_active(self, active):
"""Activate and deactivate an automation."""
url = CONST.AUTOMATION_EDIT_URL
url = url.replace(
'$AUTOMATIONID$', self.automation_id)
self._automation['is_active'] = str(int(active))
response = self._abode.send_request(
meth... | python | def set_active(self, active):
"""Activate and deactivate an automation."""
url = CONST.AUTOMATION_EDIT_URL
url = url.replace(
'$AUTOMATIONID$', self.automation_id)
self._automation['is_active'] = str(int(active))
response = self._abode.send_request(
meth... | [
"def",
"set_active",
"(",
"self",
",",
"active",
")",
":",
"url",
"=",
"CONST",
".",
"AUTOMATION_EDIT_URL",
"url",
"=",
"url",
".",
"replace",
"(",
"'$AUTOMATIONID$'",
",",
"self",
".",
"automation_id",
")",
"self",
".",
"_automation",
"[",
"'is_active'",
... | Activate and deactivate an automation. | [
"Activate",
"and",
"deactivate",
"an",
"automation",
"."
] | 6f84bb428fd1da98855f55083cd427bebbcc57ae | https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/automation.py#L18-L40 | train |
MisterWil/abodepy | abodepy/automation.py | AbodeAutomation.trigger | def trigger(self, only_manual=True):
"""Trigger a quick-action automation."""
if not self.is_quick_action and only_manual:
raise AbodeException((ERROR.TRIGGER_NON_QUICKACTION))
url = CONST.AUTOMATION_APPLY_URL
url = url.replace(
'$AUTOMATIONID$', self.automation_... | python | def trigger(self, only_manual=True):
"""Trigger a quick-action automation."""
if not self.is_quick_action and only_manual:
raise AbodeException((ERROR.TRIGGER_NON_QUICKACTION))
url = CONST.AUTOMATION_APPLY_URL
url = url.replace(
'$AUTOMATIONID$', self.automation_... | [
"def",
"trigger",
"(",
"self",
",",
"only_manual",
"=",
"True",
")",
":",
"if",
"not",
"self",
".",
"is_quick_action",
"and",
"only_manual",
":",
"raise",
"AbodeException",
"(",
"(",
"ERROR",
".",
"TRIGGER_NON_QUICKACTION",
")",
")",
"url",
"=",
"CONST",
"... | Trigger a quick-action automation. | [
"Trigger",
"a",
"quick",
"-",
"action",
"automation",
"."
] | 6f84bb428fd1da98855f55083cd427bebbcc57ae | https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/automation.py#L42-L54 | train |
MisterWil/abodepy | abodepy/automation.py | AbodeAutomation.refresh | def refresh(self):
"""Refresh the automation."""
url = CONST.AUTOMATION_ID_URL
url = url.replace(
'$AUTOMATIONID$', self.automation_id)
response = self._abode.send_request(method="get", url=url)
response_object = json.loads(response.text)
if isinstance(respo... | python | def refresh(self):
"""Refresh the automation."""
url = CONST.AUTOMATION_ID_URL
url = url.replace(
'$AUTOMATIONID$', self.automation_id)
response = self._abode.send_request(method="get", url=url)
response_object = json.loads(response.text)
if isinstance(respo... | [
"def",
"refresh",
"(",
"self",
")",
":",
"url",
"=",
"CONST",
".",
"AUTOMATION_ID_URL",
"url",
"=",
"url",
".",
"replace",
"(",
"'$AUTOMATIONID$'",
",",
"self",
".",
"automation_id",
")",
"response",
"=",
"self",
".",
"_abode",
".",
"send_request",
"(",
... | Refresh the automation. | [
"Refresh",
"the",
"automation",
"."
] | 6f84bb428fd1da98855f55083cd427bebbcc57ae | https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/automation.py#L56-L71 | train |
MisterWil/abodepy | abodepy/automation.py | AbodeAutomation.update | def update(self, automation):
"""Update the internal automation json."""
self._automation.update(
{k: automation[k] for k in automation if self._automation.get(k)}) | python | def update(self, automation):
"""Update the internal automation json."""
self._automation.update(
{k: automation[k] for k in automation if self._automation.get(k)}) | [
"def",
"update",
"(",
"self",
",",
"automation",
")",
":",
"self",
".",
"_automation",
".",
"update",
"(",
"{",
"k",
":",
"automation",
"[",
"k",
"]",
"for",
"k",
"in",
"automation",
"if",
"self",
".",
"_automation",
".",
"get",
"(",
"k",
")",
"}",... | Update the internal automation json. | [
"Update",
"the",
"internal",
"automation",
"json",
"."
] | 6f84bb428fd1da98855f55083cd427bebbcc57ae | https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/automation.py#L73-L76 | train |
MisterWil/abodepy | abodepy/automation.py | AbodeAutomation.desc | def desc(self):
"""Get a short description of the automation."""
# Auto Away (1) - Location - Enabled
active = 'inactive'
if self.is_active:
active = 'active'
return '{0} (ID: {1}) - {2} - {3}'.format(
self.name, self.automation_id, self.type, active) | python | def desc(self):
"""Get a short description of the automation."""
# Auto Away (1) - Location - Enabled
active = 'inactive'
if self.is_active:
active = 'active'
return '{0} (ID: {1}) - {2} - {3}'.format(
self.name, self.automation_id, self.type, active) | [
"def",
"desc",
"(",
"self",
")",
":",
"active",
"=",
"'inactive'",
"if",
"self",
".",
"is_active",
":",
"active",
"=",
"'active'",
"return",
"'{0} (ID: {1}) - {2} - {3}'",
".",
"format",
"(",
"self",
".",
"name",
",",
"self",
".",
"automation_id",
",",
"se... | Get a short description of the automation. | [
"Get",
"a",
"short",
"description",
"of",
"the",
"automation",
"."
] | 6f84bb428fd1da98855f55083cd427bebbcc57ae | https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/automation.py#L117-L125 | train |
MisterWil/abodepy | abodepy/devices/sensor.py | AbodeSensor._get_numeric_status | def _get_numeric_status(self, key):
"""Extract the numeric value from the statuses object."""
value = self._get_status(key)
if value and any(i.isdigit() for i in value):
return float(re.sub("[^0-9.]", "", value))
return None | python | def _get_numeric_status(self, key):
"""Extract the numeric value from the statuses object."""
value = self._get_status(key)
if value and any(i.isdigit() for i in value):
return float(re.sub("[^0-9.]", "", value))
return None | [
"def",
"_get_numeric_status",
"(",
"self",
",",
"key",
")",
":",
"value",
"=",
"self",
".",
"_get_status",
"(",
"key",
")",
"if",
"value",
"and",
"any",
"(",
"i",
".",
"isdigit",
"(",
")",
"for",
"i",
"in",
"value",
")",
":",
"return",
"float",
"("... | Extract the numeric value from the statuses object. | [
"Extract",
"the",
"numeric",
"value",
"from",
"the",
"statuses",
"object",
"."
] | 6f84bb428fd1da98855f55083cd427bebbcc57ae | https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/sensor.py#L14-L20 | train |
MisterWil/abodepy | abodepy/devices/sensor.py | AbodeSensor.temp_unit | def temp_unit(self):
"""Get unit of temp."""
if CONST.UNIT_FAHRENHEIT in self._get_status(CONST.TEMP_STATUS_KEY):
return CONST.UNIT_FAHRENHEIT
elif CONST.UNIT_CELSIUS in self._get_status(CONST.TEMP_STATUS_KEY):
return CONST.UNIT_CELSIUS
return None | python | def temp_unit(self):
"""Get unit of temp."""
if CONST.UNIT_FAHRENHEIT in self._get_status(CONST.TEMP_STATUS_KEY):
return CONST.UNIT_FAHRENHEIT
elif CONST.UNIT_CELSIUS in self._get_status(CONST.TEMP_STATUS_KEY):
return CONST.UNIT_CELSIUS
return None | [
"def",
"temp_unit",
"(",
"self",
")",
":",
"if",
"CONST",
".",
"UNIT_FAHRENHEIT",
"in",
"self",
".",
"_get_status",
"(",
"CONST",
".",
"TEMP_STATUS_KEY",
")",
":",
"return",
"CONST",
".",
"UNIT_FAHRENHEIT",
"elif",
"CONST",
".",
"UNIT_CELSIUS",
"in",
"self",... | Get unit of temp. | [
"Get",
"unit",
"of",
"temp",
"."
] | 6f84bb428fd1da98855f55083cd427bebbcc57ae | https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/sensor.py#L28-L34 | train |
MisterWil/abodepy | abodepy/devices/sensor.py | AbodeSensor.humidity_unit | def humidity_unit(self):
"""Get unit of humidity."""
if CONST.UNIT_PERCENT in self._get_status(CONST.HUMI_STATUS_KEY):
return CONST.UNIT_PERCENT
return None | python | def humidity_unit(self):
"""Get unit of humidity."""
if CONST.UNIT_PERCENT in self._get_status(CONST.HUMI_STATUS_KEY):
return CONST.UNIT_PERCENT
return None | [
"def",
"humidity_unit",
"(",
"self",
")",
":",
"if",
"CONST",
".",
"UNIT_PERCENT",
"in",
"self",
".",
"_get_status",
"(",
"CONST",
".",
"HUMI_STATUS_KEY",
")",
":",
"return",
"CONST",
".",
"UNIT_PERCENT",
"return",
"None"
] | Get unit of humidity. | [
"Get",
"unit",
"of",
"humidity",
"."
] | 6f84bb428fd1da98855f55083cd427bebbcc57ae | https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/sensor.py#L42-L46 | train |
MisterWil/abodepy | abodepy/devices/sensor.py | AbodeSensor.lux_unit | def lux_unit(self):
"""Get unit of lux."""
if CONST.UNIT_LUX in self._get_status(CONST.LUX_STATUS_KEY):
return CONST.LUX
return None | python | def lux_unit(self):
"""Get unit of lux."""
if CONST.UNIT_LUX in self._get_status(CONST.LUX_STATUS_KEY):
return CONST.LUX
return None | [
"def",
"lux_unit",
"(",
"self",
")",
":",
"if",
"CONST",
".",
"UNIT_LUX",
"in",
"self",
".",
"_get_status",
"(",
"CONST",
".",
"LUX_STATUS_KEY",
")",
":",
"return",
"CONST",
".",
"LUX",
"return",
"None"
] | Get unit of lux. | [
"Get",
"unit",
"of",
"lux",
"."
] | 6f84bb428fd1da98855f55083cd427bebbcc57ae | https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/sensor.py#L54-L58 | train |
MisterWil/abodepy | abodepy/devices/valve.py | AbodeValve.switch_on | def switch_on(self):
"""Open the valve."""
success = self.set_status(CONST.STATUS_ON_INT)
if success:
self._json_state['status'] = CONST.STATUS_OPEN
return success | python | def switch_on(self):
"""Open the valve."""
success = self.set_status(CONST.STATUS_ON_INT)
if success:
self._json_state['status'] = CONST.STATUS_OPEN
return success | [
"def",
"switch_on",
"(",
"self",
")",
":",
"success",
"=",
"self",
".",
"set_status",
"(",
"CONST",
".",
"STATUS_ON_INT",
")",
"if",
"success",
":",
"self",
".",
"_json_state",
"[",
"'status'",
"]",
"=",
"CONST",
".",
"STATUS_OPEN",
"return",
"success"
] | Open the valve. | [
"Open",
"the",
"valve",
"."
] | 6f84bb428fd1da98855f55083cd427bebbcc57ae | https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/valve.py#L10-L17 | train |
MisterWil/abodepy | abodepy/devices/valve.py | AbodeValve.switch_off | def switch_off(self):
"""Close the valve."""
success = self.set_status(CONST.STATUS_OFF_INT)
if success:
self._json_state['status'] = CONST.STATUS_CLOSED
return success | python | def switch_off(self):
"""Close the valve."""
success = self.set_status(CONST.STATUS_OFF_INT)
if success:
self._json_state['status'] = CONST.STATUS_CLOSED
return success | [
"def",
"switch_off",
"(",
"self",
")",
":",
"success",
"=",
"self",
".",
"set_status",
"(",
"CONST",
".",
"STATUS_OFF_INT",
")",
"if",
"success",
":",
"self",
".",
"_json_state",
"[",
"'status'",
"]",
"=",
"CONST",
".",
"STATUS_CLOSED",
"return",
"success"... | Close the valve. | [
"Close",
"the",
"valve",
"."
] | 6f84bb428fd1da98855f55083cd427bebbcc57ae | https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/devices/valve.py#L19-L26 | train |
MisterWil/abodepy | abodepy/socketio.py | SocketIO.set_origin | def set_origin(self, origin=None):
"""Set the Origin header."""
if origin:
self._origin = origin.encode()
else:
self._origin = None | python | def set_origin(self, origin=None):
"""Set the Origin header."""
if origin:
self._origin = origin.encode()
else:
self._origin = None | [
"def",
"set_origin",
"(",
"self",
",",
"origin",
"=",
"None",
")",
":",
"if",
"origin",
":",
"self",
".",
"_origin",
"=",
"origin",
".",
"encode",
"(",
")",
"else",
":",
"self",
".",
"_origin",
"=",
"None"
] | Set the Origin header. | [
"Set",
"the",
"Origin",
"header",
"."
] | 6f84bb428fd1da98855f55083cd427bebbcc57ae | https://github.com/MisterWil/abodepy/blob/6f84bb428fd1da98855f55083cd427bebbcc57ae/abodepy/socketio.py#L84-L89 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.