id int32 0 252k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
43,500 | dslackw/slpkg | slpkg/repoenable.py | RepoEnable.read_enabled | def read_enabled(self):
"""Read enable repositories
"""
for line in self.conf.splitlines():
line = line.lstrip()
if self.tag in line:
self.tag_line = True
if (line and self.tag_line and not line.startswith("#") and
self.tag ... | python | def read_enabled(self):
"""Read enable repositories
"""
for line in self.conf.splitlines():
line = line.lstrip()
if self.tag in line:
self.tag_line = True
if (line and self.tag_line and not line.startswith("#") and
self.tag ... | [
"def",
"read_enabled",
"(",
"self",
")",
":",
"for",
"line",
"in",
"self",
".",
"conf",
".",
"splitlines",
"(",
")",
":",
"line",
"=",
"line",
".",
"lstrip",
"(",
")",
"if",
"self",
".",
"tag",
"in",
"line",
":",
"self",
".",
"tag_line",
"=",
"Tr... | Read enable repositories | [
"Read",
"enable",
"repositories"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/repoenable.py#L76-L86 |
43,501 | dslackw/slpkg | slpkg/repoenable.py | RepoEnable.read_disabled | def read_disabled(self):
"""Read disable repositories
"""
for line in self.conf.splitlines():
line = line.lstrip()
if self.tag in line:
self.tag_line = True
if self.tag_line and line.startswith("#"):
line = "".join(line.split("#... | python | def read_disabled(self):
"""Read disable repositories
"""
for line in self.conf.splitlines():
line = line.lstrip()
if self.tag in line:
self.tag_line = True
if self.tag_line and line.startswith("#"):
line = "".join(line.split("#... | [
"def",
"read_disabled",
"(",
"self",
")",
":",
"for",
"line",
"in",
"self",
".",
"conf",
".",
"splitlines",
"(",
")",
":",
"line",
"=",
"line",
".",
"lstrip",
"(",
")",
"if",
"self",
".",
"tag",
"in",
"line",
":",
"self",
".",
"tag_line",
"=",
"T... | Read disable repositories | [
"Read",
"disable",
"repositories"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/repoenable.py#L88-L98 |
43,502 | dslackw/slpkg | slpkg/repoenable.py | RepoEnable.update_repos | def update_repos(self):
"""Update repositories.conf file with enabled or disabled
repositories
"""
with open("{0}{1}".format(self.meta.conf_path,
self.repositories_conf), "w") as new_conf:
for line in self.conf.splitlines():
l... | python | def update_repos(self):
"""Update repositories.conf file with enabled or disabled
repositories
"""
with open("{0}{1}".format(self.meta.conf_path,
self.repositories_conf), "w") as new_conf:
for line in self.conf.splitlines():
l... | [
"def",
"update_repos",
"(",
"self",
")",
":",
"with",
"open",
"(",
"\"{0}{1}\"",
".",
"format",
"(",
"self",
".",
"meta",
".",
"conf_path",
",",
"self",
".",
"repositories_conf",
")",
",",
"\"w\"",
")",
"as",
"new_conf",
":",
"for",
"line",
"in",
"self... | Update repositories.conf file with enabled or disabled
repositories | [
"Update",
"repositories",
".",
"conf",
"file",
"with",
"enabled",
"or",
"disabled",
"repositories"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/repoenable.py#L100-L121 |
43,503 | dslackw/slpkg | slpkg/repoenable.py | RepoEnable.reference | def reference(self):
"""Reference enable repositories
"""
total_enabled = ", ".join(self.selected)
if len(total_enabled) < 1:
total_enabled = ("{0}Are you crazy? This is a package "
"manager for packages :p{1}".format(
... | python | def reference(self):
"""Reference enable repositories
"""
total_enabled = ", ".join(self.selected)
if len(total_enabled) < 1:
total_enabled = ("{0}Are you crazy? This is a package "
"manager for packages :p{1}".format(
... | [
"def",
"reference",
"(",
"self",
")",
":",
"total_enabled",
"=",
"\", \"",
".",
"join",
"(",
"self",
".",
"selected",
")",
"if",
"len",
"(",
"total_enabled",
")",
"<",
"1",
":",
"total_enabled",
"=",
"(",
"\"{0}Are you crazy? This is a package \"",
"\"manager ... | Reference enable repositories | [
"Reference",
"enable",
"repositories"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/repoenable.py#L128-L144 |
43,504 | dslackw/slpkg | slpkg/sbo/search.py | sbo_search_pkg | def sbo_search_pkg(name):
"""Search for package path from SLACKBUILDS.TXT file and
return url
"""
repo = Repo().default_repository()["sbo"]
sbo_url = "{0}{1}/".format(repo, slack_ver())
SLACKBUILDS_TXT = Utils().read_file(
_meta_.lib_path + "sbo_repo/SLACKBUILDS.TXT")
for line in SLA... | python | def sbo_search_pkg(name):
"""Search for package path from SLACKBUILDS.TXT file and
return url
"""
repo = Repo().default_repository()["sbo"]
sbo_url = "{0}{1}/".format(repo, slack_ver())
SLACKBUILDS_TXT = Utils().read_file(
_meta_.lib_path + "sbo_repo/SLACKBUILDS.TXT")
for line in SLA... | [
"def",
"sbo_search_pkg",
"(",
"name",
")",
":",
"repo",
"=",
"Repo",
"(",
")",
".",
"default_repository",
"(",
")",
"[",
"\"sbo\"",
"]",
"sbo_url",
"=",
"\"{0}{1}/\"",
".",
"format",
"(",
"repo",
",",
"slack_ver",
"(",
")",
")",
"SLACKBUILDS_TXT",
"=",
... | Search for package path from SLACKBUILDS.TXT file and
return url | [
"Search",
"for",
"package",
"path",
"from",
"SLACKBUILDS",
".",
"TXT",
"file",
"and",
"return",
"url"
] | dd2e08a80e944d337d157b992167ba631a4343de | https://github.com/dslackw/slpkg/blob/dd2e08a80e944d337d157b992167ba631a4343de/slpkg/sbo/search.py#L32-L45 |
43,505 | jsommers/switchyard | examples/exercises/router/myrouter.py | Router.router_main | def router_main(self):
'''
Main method for router; we stay in a loop in this method, receiving
packets until the end of time.
'''
while True:
gotpkt = True
try:
timestamp,dev,pkt = self.net.recv_packet(timeout=1.0)
except No... | python | def router_main(self):
'''
Main method for router; we stay in a loop in this method, receiving
packets until the end of time.
'''
while True:
gotpkt = True
try:
timestamp,dev,pkt = self.net.recv_packet(timeout=1.0)
except No... | [
"def",
"router_main",
"(",
"self",
")",
":",
"while",
"True",
":",
"gotpkt",
"=",
"True",
"try",
":",
"timestamp",
",",
"dev",
",",
"pkt",
"=",
"self",
".",
"net",
".",
"recv_packet",
"(",
"timeout",
"=",
"1.0",
")",
"except",
"NoPackets",
":",
"log_... | Main method for router; we stay in a loop in this method, receiving
packets until the end of time. | [
"Main",
"method",
"for",
"router",
";",
"we",
"stay",
"in",
"a",
"loop",
"in",
"this",
"method",
"receiving",
"packets",
"until",
"the",
"end",
"of",
"time",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/examples/exercises/router/myrouter.py#L18-L35 |
43,506 | bronto/javasphinx | javasphinx/apidoc.py | find_source_files | def find_source_files(input_path, excludes):
""" Get a list of filenames for all Java source files within the given
directory.
"""
java_files = []
input_path = os.path.normpath(os.path.abspath(input_path))
for dirpath, dirnames, filenames in os.walk(input_path):
if is_excluded(dirpat... | python | def find_source_files(input_path, excludes):
""" Get a list of filenames for all Java source files within the given
directory.
"""
java_files = []
input_path = os.path.normpath(os.path.abspath(input_path))
for dirpath, dirnames, filenames in os.walk(input_path):
if is_excluded(dirpat... | [
"def",
"find_source_files",
"(",
"input_path",
",",
"excludes",
")",
":",
"java_files",
"=",
"[",
"]",
"input_path",
"=",
"os",
".",
"path",
".",
"normpath",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"input_path",
")",
")",
"for",
"dirpath",
",",
"d... | Get a list of filenames for all Java source files within the given
directory. | [
"Get",
"a",
"list",
"of",
"filenames",
"for",
"all",
"Java",
"source",
"files",
"within",
"the",
"given",
"directory",
"."
] | cd1df27f1d70efaae079b74573efdd8e069ff02d | https://github.com/bronto/javasphinx/blob/cd1df27f1d70efaae079b74573efdd8e069ff02d/javasphinx/apidoc.py#L43-L62 |
43,507 | jsommers/switchyard | switchyard/lib/packet/ipv4.py | IPOptionList.from_bytes | def from_bytes(rawbytes):
'''
Takes a byte string as a parameter and returns a list of
IPOption objects.
'''
ipopts = IPOptionList()
i = 0
while i < len(rawbytes):
opttype = rawbytes[i]
optcopied = opttype >> 7 # high order 1 bit
... | python | def from_bytes(rawbytes):
'''
Takes a byte string as a parameter and returns a list of
IPOption objects.
'''
ipopts = IPOptionList()
i = 0
while i < len(rawbytes):
opttype = rawbytes[i]
optcopied = opttype >> 7 # high order 1 bit
... | [
"def",
"from_bytes",
"(",
"rawbytes",
")",
":",
"ipopts",
"=",
"IPOptionList",
"(",
")",
"i",
"=",
"0",
"while",
"i",
"<",
"len",
"(",
"rawbytes",
")",
":",
"opttype",
"=",
"rawbytes",
"[",
"i",
"]",
"optcopied",
"=",
"opttype",
">>",
"7",
"# high or... | Takes a byte string as a parameter and returns a list of
IPOption objects. | [
"Takes",
"a",
"byte",
"string",
"as",
"a",
"parameter",
"and",
"returns",
"a",
"list",
"of",
"IPOption",
"objects",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/ipv4.py#L289-L307 |
43,508 | jsommers/switchyard | switchyard/lib/packet/ipv4.py | IPOptionList.to_bytes | def to_bytes(self):
'''
Takes a list of IPOption objects and returns a packed byte string
of options, appropriately padded if necessary.
'''
raw = b''
if not self._options:
return raw
for ipopt in self._options:
raw += ipopt.to_bytes()
... | python | def to_bytes(self):
'''
Takes a list of IPOption objects and returns a packed byte string
of options, appropriately padded if necessary.
'''
raw = b''
if not self._options:
return raw
for ipopt in self._options:
raw += ipopt.to_bytes()
... | [
"def",
"to_bytes",
"(",
"self",
")",
":",
"raw",
"=",
"b''",
"if",
"not",
"self",
".",
"_options",
":",
"return",
"raw",
"for",
"ipopt",
"in",
"self",
".",
"_options",
":",
"raw",
"+=",
"ipopt",
".",
"to_bytes",
"(",
")",
"padbytes",
"=",
"4",
"-",... | Takes a list of IPOption objects and returns a packed byte string
of options, appropriately padded if necessary. | [
"Takes",
"a",
"list",
"of",
"IPOption",
"objects",
"and",
"returns",
"a",
"packed",
"byte",
"string",
"of",
"options",
"appropriately",
"padded",
"if",
"necessary",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/ipv4.py#L309-L321 |
43,509 | jsommers/switchyard | switchyard/llnetbase.py | _start_usercode | def _start_usercode(entryfunction, netobj, codeargdict):
'''
figure out how to correctly start the user code. warn if
args are passed on the command line, but the code doesn't
accept them.
'''
# p22, python3 lang ref
numargs = entryfunction.__code__.co_argcount
takenet = numargs >= 1
... | python | def _start_usercode(entryfunction, netobj, codeargdict):
'''
figure out how to correctly start the user code. warn if
args are passed on the command line, but the code doesn't
accept them.
'''
# p22, python3 lang ref
numargs = entryfunction.__code__.co_argcount
takenet = numargs >= 1
... | [
"def",
"_start_usercode",
"(",
"entryfunction",
",",
"netobj",
",",
"codeargdict",
")",
":",
"# p22, python3 lang ref",
"numargs",
"=",
"entryfunction",
".",
"__code__",
".",
"co_argcount",
"takenet",
"=",
"numargs",
">=",
"1",
"takestarargs",
"=",
"entryfunction",
... | figure out how to correctly start the user code. warn if
args are passed on the command line, but the code doesn't
accept them. | [
"figure",
"out",
"how",
"to",
"correctly",
"start",
"the",
"user",
"code",
".",
"warn",
"if",
"args",
"are",
"passed",
"on",
"the",
"command",
"line",
"but",
"the",
"code",
"doesn",
"t",
"accept",
"them",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/llnetbase.py#L12-L46 |
43,510 | jsommers/switchyard | switchyard/llnetbase.py | LLNetBase.interface_by_name | def interface_by_name(self, name):
'''
Given a device name, return the corresponding interface object
'''
if name in self._devinfo:
return self._devinfo[name]
raise KeyError("No device named {}".format(name)) | python | def interface_by_name(self, name):
'''
Given a device name, return the corresponding interface object
'''
if name in self._devinfo:
return self._devinfo[name]
raise KeyError("No device named {}".format(name)) | [
"def",
"interface_by_name",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"_devinfo",
":",
"return",
"self",
".",
"_devinfo",
"[",
"name",
"]",
"raise",
"KeyError",
"(",
"\"No device named {}\"",
".",
"format",
"(",
"name",
")",
")... | Given a device name, return the corresponding interface object | [
"Given",
"a",
"device",
"name",
"return",
"the",
"corresponding",
"interface",
"object"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/llnetbase.py#L105-L111 |
43,511 | jsommers/switchyard | switchyard/llnetbase.py | LLNetBase.interface_by_ipaddr | def interface_by_ipaddr(self, ipaddr):
'''
Given an IP address, return the interface that 'owns' this address
'''
ipaddr = IPAddr(ipaddr)
for devname,iface in self._devinfo.items():
if iface.ipaddr == ipaddr:
return iface
raise KeyError("No dev... | python | def interface_by_ipaddr(self, ipaddr):
'''
Given an IP address, return the interface that 'owns' this address
'''
ipaddr = IPAddr(ipaddr)
for devname,iface in self._devinfo.items():
if iface.ipaddr == ipaddr:
return iface
raise KeyError("No dev... | [
"def",
"interface_by_ipaddr",
"(",
"self",
",",
"ipaddr",
")",
":",
"ipaddr",
"=",
"IPAddr",
"(",
"ipaddr",
")",
"for",
"devname",
",",
"iface",
"in",
"self",
".",
"_devinfo",
".",
"items",
"(",
")",
":",
"if",
"iface",
".",
"ipaddr",
"==",
"ipaddr",
... | Given an IP address, return the interface that 'owns' this address | [
"Given",
"an",
"IP",
"address",
"return",
"the",
"interface",
"that",
"owns",
"this",
"address"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/llnetbase.py#L119-L127 |
43,512 | jsommers/switchyard | switchyard/llnetbase.py | LLNetBase.interface_by_macaddr | def interface_by_macaddr(self, macaddr):
'''
Given a MAC address, return the interface that 'owns' this address
'''
macaddr = EthAddr(macaddr)
for devname,iface in self._devinfo.items():
if iface.ethaddr == macaddr:
return iface
raise KeyError(... | python | def interface_by_macaddr(self, macaddr):
'''
Given a MAC address, return the interface that 'owns' this address
'''
macaddr = EthAddr(macaddr)
for devname,iface in self._devinfo.items():
if iface.ethaddr == macaddr:
return iface
raise KeyError(... | [
"def",
"interface_by_macaddr",
"(",
"self",
",",
"macaddr",
")",
":",
"macaddr",
"=",
"EthAddr",
"(",
"macaddr",
")",
"for",
"devname",
",",
"iface",
"in",
"self",
".",
"_devinfo",
".",
"items",
"(",
")",
":",
"if",
"iface",
".",
"ethaddr",
"==",
"maca... | Given a MAC address, return the interface that 'owns' this address | [
"Given",
"a",
"MAC",
"address",
"return",
"the",
"interface",
"that",
"owns",
"this",
"address"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/llnetbase.py#L135-L143 |
43,513 | jsommers/switchyard | switchyard/lib/packet/icmpv6.py | ICMPv6OptionList.from_bytes | def from_bytes(rawbytes):
'''
Takes a byte string as a parameter and returns a list of
ICMPv6Option objects.
'''
icmpv6popts = ICMPv6OptionList()
i = 0
while i < len(rawbytes):
opttype = rawbytes[i]
optnum = ICMPv6OptionNumber(opttype)
... | python | def from_bytes(rawbytes):
'''
Takes a byte string as a parameter and returns a list of
ICMPv6Option objects.
'''
icmpv6popts = ICMPv6OptionList()
i = 0
while i < len(rawbytes):
opttype = rawbytes[i]
optnum = ICMPv6OptionNumber(opttype)
... | [
"def",
"from_bytes",
"(",
"rawbytes",
")",
":",
"icmpv6popts",
"=",
"ICMPv6OptionList",
"(",
")",
"i",
"=",
"0",
"while",
"i",
"<",
"len",
"(",
"rawbytes",
")",
":",
"opttype",
"=",
"rawbytes",
"[",
"i",
"]",
"optnum",
"=",
"ICMPv6OptionNumber",
"(",
"... | Takes a byte string as a parameter and returns a list of
ICMPv6Option objects. | [
"Takes",
"a",
"byte",
"string",
"as",
"a",
"parameter",
"and",
"returns",
"a",
"list",
"of",
"ICMPv6Option",
"objects",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/icmpv6.py#L197-L212 |
43,514 | jsommers/switchyard | switchyard/lib/packet/icmpv6.py | ICMPv6OptionList.to_bytes | def to_bytes(self):
'''
Takes a list of ICMPv6Option objects and returns a packed byte string
of options, appropriately padded if necessary.
'''
raw = b''
if not self._options:
return raw
for icmpv6popt in self._options:
raw += icmpv6popt.t... | python | def to_bytes(self):
'''
Takes a list of ICMPv6Option objects and returns a packed byte string
of options, appropriately padded if necessary.
'''
raw = b''
if not self._options:
return raw
for icmpv6popt in self._options:
raw += icmpv6popt.t... | [
"def",
"to_bytes",
"(",
"self",
")",
":",
"raw",
"=",
"b''",
"if",
"not",
"self",
".",
"_options",
":",
"return",
"raw",
"for",
"icmpv6popt",
"in",
"self",
".",
"_options",
":",
"raw",
"+=",
"icmpv6popt",
".",
"to_bytes",
"(",
")",
"# Padding doesn't see... | Takes a list of ICMPv6Option objects and returns a packed byte string
of options, appropriately padded if necessary. | [
"Takes",
"a",
"list",
"of",
"ICMPv6Option",
"objects",
"and",
"returns",
"a",
"packed",
"byte",
"string",
"of",
"options",
"appropriately",
"padded",
"if",
"necessary",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/icmpv6.py#L214-L230 |
43,515 | jsommers/switchyard | switchyard/lib/openflow/openflow10.py | _unpack_bitmap | def _unpack_bitmap(bitmap, xenum):
'''
Given an integer bitmap and an enumerated type, build
a set that includes zero or more enumerated type values
corresponding to the bitmap.
'''
unpacked = set()
for enval in xenum:
if enval.value & bitmap == enval.value:
unpacked.add(... | python | def _unpack_bitmap(bitmap, xenum):
'''
Given an integer bitmap and an enumerated type, build
a set that includes zero or more enumerated type values
corresponding to the bitmap.
'''
unpacked = set()
for enval in xenum:
if enval.value & bitmap == enval.value:
unpacked.add(... | [
"def",
"_unpack_bitmap",
"(",
"bitmap",
",",
"xenum",
")",
":",
"unpacked",
"=",
"set",
"(",
")",
"for",
"enval",
"in",
"xenum",
":",
"if",
"enval",
".",
"value",
"&",
"bitmap",
"==",
"enval",
".",
"value",
":",
"unpacked",
".",
"add",
"(",
"enval",
... | Given an integer bitmap and an enumerated type, build
a set that includes zero or more enumerated type values
corresponding to the bitmap. | [
"Given",
"an",
"integer",
"bitmap",
"and",
"an",
"enumerated",
"type",
"build",
"a",
"set",
"that",
"includes",
"zero",
"or",
"more",
"enumerated",
"type",
"values",
"corresponding",
"to",
"the",
"bitmap",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/openflow/openflow10.py#L21-L31 |
43,516 | jsommers/switchyard | switchyard/lib/openflow/openflow10.py | _make_wildcard_attr_map | def _make_wildcard_attr_map():
'''
Create a dictionary that maps an attribute name
in OpenflowMatch with a non-prefix-related wildcard
bit from the above OpenflowWildcard enumeration.
'''
_xmap = {}
for wc in OpenflowWildcard:
if not wc.name.endswith('All') and \
not wc.n... | python | def _make_wildcard_attr_map():
'''
Create a dictionary that maps an attribute name
in OpenflowMatch with a non-prefix-related wildcard
bit from the above OpenflowWildcard enumeration.
'''
_xmap = {}
for wc in OpenflowWildcard:
if not wc.name.endswith('All') and \
not wc.n... | [
"def",
"_make_wildcard_attr_map",
"(",
")",
":",
"_xmap",
"=",
"{",
"}",
"for",
"wc",
"in",
"OpenflowWildcard",
":",
"if",
"not",
"wc",
".",
"name",
".",
"endswith",
"(",
"'All'",
")",
"and",
"not",
"wc",
".",
"name",
".",
"endswith",
"(",
"'Mask'",
... | Create a dictionary that maps an attribute name
in OpenflowMatch with a non-prefix-related wildcard
bit from the above OpenflowWildcard enumeration. | [
"Create",
"a",
"dictionary",
"that",
"maps",
"an",
"attribute",
"name",
"in",
"OpenflowMatch",
"with",
"a",
"non",
"-",
"prefix",
"-",
"related",
"wildcard",
"bit",
"from",
"the",
"above",
"OpenflowWildcard",
"enumeration",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/openflow/openflow10.py#L761-L779 |
43,517 | jsommers/switchyard | switchyard/lib/openflow/openflow10.py | OpenflowMatch.matches_packet | def matches_packet(self, pkt):
'''
Return True if the given packet matches this match object.
'''
match = []
wildbits = _make_bitmap(self._wildcards)
for mf,pkttuple in OpenflowMatch._match_field_to_packet.items():
mf = "_{}".format(mf)
# if the a... | python | def matches_packet(self, pkt):
'''
Return True if the given packet matches this match object.
'''
match = []
wildbits = _make_bitmap(self._wildcards)
for mf,pkttuple in OpenflowMatch._match_field_to_packet.items():
mf = "_{}".format(mf)
# if the a... | [
"def",
"matches_packet",
"(",
"self",
",",
"pkt",
")",
":",
"match",
"=",
"[",
"]",
"wildbits",
"=",
"_make_bitmap",
"(",
"self",
".",
"_wildcards",
")",
"for",
"mf",
",",
"pkttuple",
"in",
"OpenflowMatch",
".",
"_match_field_to_packet",
".",
"items",
"(",... | Return True if the given packet matches this match object. | [
"Return",
"True",
"if",
"the",
"given",
"packet",
"matches",
"this",
"match",
"object",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/openflow/openflow10.py#L537-L566 |
43,518 | jsommers/switchyard | switchyard/lib/openflow/openflow10.py | OpenflowMatch.build_from_packet | def build_from_packet(pkt):
'''
Build and return a new OpenflowMatch object based on the
packet object passed as a parameter.
'''
m = OpenflowMatch()
for mf,pkttuple in OpenflowMatch._match_field_to_packet.items():
for pktcls,field in pkttuple:
... | python | def build_from_packet(pkt):
'''
Build and return a new OpenflowMatch object based on the
packet object passed as a parameter.
'''
m = OpenflowMatch()
for mf,pkttuple in OpenflowMatch._match_field_to_packet.items():
for pktcls,field in pkttuple:
... | [
"def",
"build_from_packet",
"(",
"pkt",
")",
":",
"m",
"=",
"OpenflowMatch",
"(",
")",
"for",
"mf",
",",
"pkttuple",
"in",
"OpenflowMatch",
".",
"_match_field_to_packet",
".",
"items",
"(",
")",
":",
"for",
"pktcls",
",",
"field",
"in",
"pkttuple",
":",
... | Build and return a new OpenflowMatch object based on the
packet object passed as a parameter. | [
"Build",
"and",
"return",
"a",
"new",
"OpenflowMatch",
"object",
"based",
"on",
"the",
"packet",
"object",
"passed",
"as",
"a",
"parameter",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/openflow/openflow10.py#L569-L580 |
43,519 | jsommers/switchyard | switchyard/lib/openflow/openflow10.py | OpenflowHeader.pre_serialize | def pre_serialize(self, raw, pkt, i):
'''
Set length of the header based on
'''
self.length = len(raw) + OpenflowHeader._MINLEN | python | def pre_serialize(self, raw, pkt, i):
'''
Set length of the header based on
'''
self.length = len(raw) + OpenflowHeader._MINLEN | [
"def",
"pre_serialize",
"(",
"self",
",",
"raw",
",",
"pkt",
",",
"i",
")",
":",
"self",
".",
"length",
"=",
"len",
"(",
"raw",
")",
"+",
"OpenflowHeader",
".",
"_MINLEN"
] | Set length of the header based on | [
"Set",
"length",
"of",
"the",
"header",
"based",
"on"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/openflow/openflow10.py#L3378-L3382 |
43,520 | jsommers/switchyard | switchyard/pcapffi.py | _PcapFfi.discoverdevs | def discoverdevs(self):
'''
Find all the pcap-eligible devices on the local system.
'''
if len(self._interfaces):
raise PcapException("Device discovery should only be done once.")
ppintf = self._ffi.new("pcap_if_t * *")
errbuf = self._ffi.new("cha... | python | def discoverdevs(self):
'''
Find all the pcap-eligible devices on the local system.
'''
if len(self._interfaces):
raise PcapException("Device discovery should only be done once.")
ppintf = self._ffi.new("pcap_if_t * *")
errbuf = self._ffi.new("cha... | [
"def",
"discoverdevs",
"(",
"self",
")",
":",
"if",
"len",
"(",
"self",
".",
"_interfaces",
")",
":",
"raise",
"PcapException",
"(",
"\"Device discovery should only be done once.\"",
")",
"ppintf",
"=",
"self",
".",
"_ffi",
".",
"new",
"(",
"\"pcap_if_t * *\"",
... | Find all the pcap-eligible devices on the local system. | [
"Find",
"all",
"the",
"pcap",
"-",
"eligible",
"devices",
"on",
"the",
"local",
"system",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/pcapffi.py#L208-L254 |
43,521 | jsommers/switchyard | switchyard/pcapffi.py | PcapLiveDevice.set_bpf_filter_on_all_devices | def set_bpf_filter_on_all_devices(filterstr):
'''
Long method name, but self-explanatory. Set the bpf
filter on all devices that have been opened.
'''
with PcapLiveDevice._lock:
for dev in PcapLiveDevice._OpenDevices.values():
_PcapFfi.instance()._set... | python | def set_bpf_filter_on_all_devices(filterstr):
'''
Long method name, but self-explanatory. Set the bpf
filter on all devices that have been opened.
'''
with PcapLiveDevice._lock:
for dev in PcapLiveDevice._OpenDevices.values():
_PcapFfi.instance()._set... | [
"def",
"set_bpf_filter_on_all_devices",
"(",
"filterstr",
")",
":",
"with",
"PcapLiveDevice",
".",
"_lock",
":",
"for",
"dev",
"in",
"PcapLiveDevice",
".",
"_OpenDevices",
".",
"values",
"(",
")",
":",
"_PcapFfi",
".",
"instance",
"(",
")",
".",
"_set_filter",... | Long method name, but self-explanatory. Set the bpf
filter on all devices that have been opened. | [
"Long",
"method",
"name",
"but",
"self",
"-",
"explanatory",
".",
"Set",
"the",
"bpf",
"filter",
"on",
"all",
"devices",
"that",
"have",
"been",
"opened",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/pcapffi.py#L568-L575 |
43,522 | jsommers/switchyard | switchyard/lib/packet/util.py | create_ip_arp_request | def create_ip_arp_request(srchw, srcip, targetip):
'''
Create and return a packet containing an Ethernet header
and ARP header.
'''
ether = Ethernet()
ether.src = srchw
ether.dst = SpecialEthAddr.ETHER_BROADCAST.value
ether.ethertype = EtherType.ARP
arp = Arp()
arp.operation = Ar... | python | def create_ip_arp_request(srchw, srcip, targetip):
'''
Create and return a packet containing an Ethernet header
and ARP header.
'''
ether = Ethernet()
ether.src = srchw
ether.dst = SpecialEthAddr.ETHER_BROADCAST.value
ether.ethertype = EtherType.ARP
arp = Arp()
arp.operation = Ar... | [
"def",
"create_ip_arp_request",
"(",
"srchw",
",",
"srcip",
",",
"targetip",
")",
":",
"ether",
"=",
"Ethernet",
"(",
")",
"ether",
".",
"src",
"=",
"srchw",
"ether",
".",
"dst",
"=",
"SpecialEthAddr",
".",
"ETHER_BROADCAST",
".",
"value",
"ether",
".",
... | Create and return a packet containing an Ethernet header
and ARP header. | [
"Create",
"and",
"return",
"a",
"packet",
"containing",
"an",
"Ethernet",
"header",
"and",
"ARP",
"header",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/util.py#L14-L29 |
43,523 | jsommers/switchyard | switchyard/lib/logging.py | setup_logging | def setup_logging(debug, logfile=None):
'''
Setup logging format and log level.
'''
if debug:
level = logging.DEBUG
else:
level = logging.INFO
if logfile is not None:
logging.basicConfig(format="%(asctime)s %(levelname)8s %(message)s", datefmt="%H:%M:%S %Y/%m/%d", level=l... | python | def setup_logging(debug, logfile=None):
'''
Setup logging format and log level.
'''
if debug:
level = logging.DEBUG
else:
level = logging.INFO
if logfile is not None:
logging.basicConfig(format="%(asctime)s %(levelname)8s %(message)s", datefmt="%H:%M:%S %Y/%m/%d", level=l... | [
"def",
"setup_logging",
"(",
"debug",
",",
"logfile",
"=",
"None",
")",
":",
"if",
"debug",
":",
"level",
"=",
"logging",
".",
"DEBUG",
"else",
":",
"level",
"=",
"logging",
".",
"INFO",
"if",
"logfile",
"is",
"not",
"None",
":",
"logging",
".",
"bas... | Setup logging format and log level. | [
"Setup",
"logging",
"format",
"and",
"log",
"level",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/logging.py#L6-L17 |
43,524 | jsommers/switchyard | switchyard/llnetreal.py | LLNetReal._spawn_threads | def _spawn_threads(self):
'''
Internal method. Creates threads to handle low-level
network receive.
'''
for devname,pdev in self._pcaps.items():
t = threading.Thread(target=LLNetReal._low_level_dispatch, args=(pdev, devname, self._pktqueue))
t.start()
... | python | def _spawn_threads(self):
'''
Internal method. Creates threads to handle low-level
network receive.
'''
for devname,pdev in self._pcaps.items():
t = threading.Thread(target=LLNetReal._low_level_dispatch, args=(pdev, devname, self._pktqueue))
t.start()
... | [
"def",
"_spawn_threads",
"(",
"self",
")",
":",
"for",
"devname",
",",
"pdev",
"in",
"self",
".",
"_pcaps",
".",
"items",
"(",
")",
":",
"t",
"=",
"threading",
".",
"Thread",
"(",
"target",
"=",
"LLNetReal",
".",
"_low_level_dispatch",
",",
"args",
"="... | Internal method. Creates threads to handle low-level
network receive. | [
"Internal",
"method",
".",
"Creates",
"threads",
"to",
"handle",
"low",
"-",
"level",
"network",
"receive",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/llnetreal.py#L90-L98 |
43,525 | jsommers/switchyard | switchyard/llnetreal.py | LLNetReal._make_pcaps | def _make_pcaps(self):
'''
Internal method. Create libpcap devices
for every network interface we care about and
set them in non-blocking mode.
'''
self._pcaps = {}
for devname,intf in self._devinfo.items():
if intf.iftype == InterfaceType.Loopback:
... | python | def _make_pcaps(self):
'''
Internal method. Create libpcap devices
for every network interface we care about and
set them in non-blocking mode.
'''
self._pcaps = {}
for devname,intf in self._devinfo.items():
if intf.iftype == InterfaceType.Loopback:
... | [
"def",
"_make_pcaps",
"(",
"self",
")",
":",
"self",
".",
"_pcaps",
"=",
"{",
"}",
"for",
"devname",
",",
"intf",
"in",
"self",
".",
"_devinfo",
".",
"items",
"(",
")",
":",
"if",
"intf",
".",
"iftype",
"==",
"InterfaceType",
".",
"Loopback",
":",
... | Internal method. Create libpcap devices
for every network interface we care about and
set them in non-blocking mode. | [
"Internal",
"method",
".",
"Create",
"libpcap",
"devices",
"for",
"every",
"network",
"interface",
"we",
"care",
"about",
"and",
"set",
"them",
"in",
"non",
"-",
"blocking",
"mode",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/llnetreal.py#L149-L161 |
43,526 | jsommers/switchyard | switchyard/llnetreal.py | LLNetReal._sig_handler | def _sig_handler(self, signum, stack):
'''
Handle process INT signal.
'''
log_debug("Got SIGINT.")
if signum == signal.SIGINT:
LLNetReal.running = False
if self._pktqueue.qsize() == 0:
# put dummy pkt in queue to unblock a
... | python | def _sig_handler(self, signum, stack):
'''
Handle process INT signal.
'''
log_debug("Got SIGINT.")
if signum == signal.SIGINT:
LLNetReal.running = False
if self._pktqueue.qsize() == 0:
# put dummy pkt in queue to unblock a
... | [
"def",
"_sig_handler",
"(",
"self",
",",
"signum",
",",
"stack",
")",
":",
"log_debug",
"(",
"\"Got SIGINT.\"",
")",
"if",
"signum",
"==",
"signal",
".",
"SIGINT",
":",
"LLNetReal",
".",
"running",
"=",
"False",
"if",
"self",
".",
"_pktqueue",
".",
"qsiz... | Handle process INT signal. | [
"Handle",
"process",
"INT",
"signal",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/llnetreal.py#L163-L173 |
43,527 | jsommers/switchyard | switchyard/llnetreal.py | LLNetReal._low_level_dispatch | def _low_level_dispatch(pcapdev, devname, pktqueue):
'''
Thread entrypoint for doing low-level receive and dispatch
for a single pcap device.
'''
while LLNetReal.running:
# a non-zero timeout value is ok here; this is an
# independent thread that handles i... | python | def _low_level_dispatch(pcapdev, devname, pktqueue):
'''
Thread entrypoint for doing low-level receive and dispatch
for a single pcap device.
'''
while LLNetReal.running:
# a non-zero timeout value is ok here; this is an
# independent thread that handles i... | [
"def",
"_low_level_dispatch",
"(",
"pcapdev",
",",
"devname",
",",
"pktqueue",
")",
":",
"while",
"LLNetReal",
".",
"running",
":",
"# a non-zero timeout value is ok here; this is an",
"# independent thread that handles input for this",
"# one pcap device. it throws any packets re... | Thread entrypoint for doing low-level receive and dispatch
for a single pcap device. | [
"Thread",
"entrypoint",
"for",
"doing",
"low",
"-",
"level",
"receive",
"and",
"dispatch",
"for",
"a",
"single",
"pcap",
"device",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/llnetreal.py#L176-L194 |
43,528 | bronto/javasphinx | javasphinx/compiler.py | JavadocRestCompiler.__output_see | def __output_see(self, see):
""" Convert the argument to a @see tag to rest """
if see.startswith('<a href'):
# HTML link -- <a href="...">...</a>
return self.__html_to_rst(see)
elif '"' in see:
# Plain text
return see
else:
# ... | python | def __output_see(self, see):
""" Convert the argument to a @see tag to rest """
if see.startswith('<a href'):
# HTML link -- <a href="...">...</a>
return self.__html_to_rst(see)
elif '"' in see:
# Plain text
return see
else:
# ... | [
"def",
"__output_see",
"(",
"self",
",",
"see",
")",
":",
"if",
"see",
".",
"startswith",
"(",
"'<a href'",
")",
":",
"# HTML link -- <a href=\"...\">...</a>",
"return",
"self",
".",
"__html_to_rst",
"(",
"see",
")",
"elif",
"'\"'",
"in",
"see",
":",
"# Plai... | Convert the argument to a @see tag to rest | [
"Convert",
"the",
"argument",
"to",
"a"
] | cd1df27f1d70efaae079b74573efdd8e069ff02d | https://github.com/bronto/javasphinx/blob/cd1df27f1d70efaae079b74573efdd8e069ff02d/javasphinx/compiler.py#L95-L106 |
43,529 | bronto/javasphinx | javasphinx/compiler.py | JavadocRestCompiler.compile_type_document | def compile_type_document(self, imports_block, package, name, declaration):
""" Compile a complete document, documenting a type and its members """
outer_type = name.rpartition('.')[0]
document = util.Document()
document.add(imports_block)
document.add_heading(name, '=')
... | python | def compile_type_document(self, imports_block, package, name, declaration):
""" Compile a complete document, documenting a type and its members """
outer_type = name.rpartition('.')[0]
document = util.Document()
document.add(imports_block)
document.add_heading(name, '=')
... | [
"def",
"compile_type_document",
"(",
"self",
",",
"imports_block",
",",
"package",
",",
"name",
",",
"declaration",
")",
":",
"outer_type",
"=",
"name",
".",
"rpartition",
"(",
"'.'",
")",
"[",
"0",
"]",
"document",
"=",
"util",
".",
"Document",
"(",
")"... | Compile a complete document, documenting a type and its members | [
"Compile",
"a",
"complete",
"document",
"documenting",
"a",
"type",
"and",
"its",
"members"
] | cd1df27f1d70efaae079b74573efdd8e069ff02d | https://github.com/bronto/javasphinx/blob/cd1df27f1d70efaae079b74573efdd8e069ff02d/javasphinx/compiler.py#L221-L288 |
43,530 | bronto/javasphinx | javasphinx/compiler.py | JavadocRestCompiler.compile | def compile(self, ast):
""" Compile autodocs for the given Java syntax tree. Documents will be
returned documenting each separate type. """
documents = {}
imports = util.StringBuilder()
for imp in ast.imports:
if imp.static or imp.wildcard:
continue
... | python | def compile(self, ast):
""" Compile autodocs for the given Java syntax tree. Documents will be
returned documenting each separate type. """
documents = {}
imports = util.StringBuilder()
for imp in ast.imports:
if imp.static or imp.wildcard:
continue
... | [
"def",
"compile",
"(",
"self",
",",
"ast",
")",
":",
"documents",
"=",
"{",
"}",
"imports",
"=",
"util",
".",
"StringBuilder",
"(",
")",
"for",
"imp",
"in",
"ast",
".",
"imports",
":",
"if",
"imp",
".",
"static",
"or",
"imp",
".",
"wildcard",
":",
... | Compile autodocs for the given Java syntax tree. Documents will be
returned documenting each separate type. | [
"Compile",
"autodocs",
"for",
"the",
"given",
"Java",
"syntax",
"tree",
".",
"Documents",
"will",
"be",
"returned",
"documenting",
"each",
"separate",
"type",
"."
] | cd1df27f1d70efaae079b74573efdd8e069ff02d | https://github.com/bronto/javasphinx/blob/cd1df27f1d70efaae079b74573efdd8e069ff02d/javasphinx/compiler.py#L290-L341 |
43,531 | jsommers/switchyard | switchyard/lib/packet/common.py | checksum | def checksum (data, start = 0, skip_word = None):
"""
Calculate standard internet checksum over data starting at start'th byte
skip_word: If specified, it's the word offset of a word in data to "skip"
(as if it were zero). The purpose is when data is received
data which contains a comp... | python | def checksum (data, start = 0, skip_word = None):
"""
Calculate standard internet checksum over data starting at start'th byte
skip_word: If specified, it's the word offset of a word in data to "skip"
(as if it were zero). The purpose is when data is received
data which contains a comp... | [
"def",
"checksum",
"(",
"data",
",",
"start",
"=",
"0",
",",
"skip_word",
"=",
"None",
")",
":",
"if",
"len",
"(",
"data",
")",
"%",
"2",
"!=",
"0",
":",
"arr",
"=",
"array",
".",
"array",
"(",
"'H'",
",",
"data",
"[",
":",
"-",
"1",
"]",
"... | Calculate standard internet checksum over data starting at start'th byte
skip_word: If specified, it's the word offset of a word in data to "skip"
(as if it were zero). The purpose is when data is received
data which contains a computed checksum that you are trying to
verify -... | [
"Calculate",
"standard",
"internet",
"checksum",
"over",
"data",
"starting",
"at",
"start",
"th",
"byte"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/common.py#L317-L349 |
43,532 | bronto/javasphinx | javasphinx/extdoc.py | javadoc_role | def javadoc_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
""" Role for linking to external Javadoc """
has_explicit_title, title, target = split_explicit_title(text)
title = utils.unescape(title)
target = utils.unescape(target)
if not has_explicit_title:
target = targ... | python | def javadoc_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
""" Role for linking to external Javadoc """
has_explicit_title, title, target = split_explicit_title(text)
title = utils.unescape(title)
target = utils.unescape(target)
if not has_explicit_title:
target = targ... | [
"def",
"javadoc_role",
"(",
"name",
",",
"rawtext",
",",
"text",
",",
"lineno",
",",
"inliner",
",",
"options",
"=",
"{",
"}",
",",
"content",
"=",
"[",
"]",
")",
":",
"has_explicit_title",
",",
"title",
",",
"target",
"=",
"split_explicit_title",
"(",
... | Role for linking to external Javadoc | [
"Role",
"for",
"linking",
"to",
"external",
"Javadoc"
] | cd1df27f1d70efaae079b74573efdd8e069ff02d | https://github.com/bronto/javasphinx/blob/cd1df27f1d70efaae079b74573efdd8e069ff02d/javasphinx/extdoc.py#L103-L124 |
43,533 | jsommers/switchyard | switchyard/lib/openflow/ofswitch.py | PacketBufferManager.add | def add(self, port, pkt):
'''
Add new input port + packet to buffer.
'''
id = len(self._buffer) + 1
if id > self._buffsize:
raise FullBuffer()
self._buffer[id] = (port, deepcopy(pkt))
return id | python | def add(self, port, pkt):
'''
Add new input port + packet to buffer.
'''
id = len(self._buffer) + 1
if id > self._buffsize:
raise FullBuffer()
self._buffer[id] = (port, deepcopy(pkt))
return id | [
"def",
"add",
"(",
"self",
",",
"port",
",",
"pkt",
")",
":",
"id",
"=",
"len",
"(",
"self",
".",
"_buffer",
")",
"+",
"1",
"if",
"id",
">",
"self",
".",
"_buffsize",
":",
"raise",
"FullBuffer",
"(",
")",
"self",
".",
"_buffer",
"[",
"id",
"]",... | Add new input port + packet to buffer. | [
"Add",
"new",
"input",
"port",
"+",
"packet",
"to",
"buffer",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/openflow/ofswitch.py#L101-L110 |
43,534 | jsommers/switchyard | switchyard/lib/openflow/ofswitch.py | OpenflowSwitch._handle_datapath | def _handle_datapath(self, inport, packet):
'''
Handle single packet on the data plane.
'''
inport = self._switchyard_net.port_by_name(inport)
portnum = inport.ifnum
log_info("Processing packet: {}->{}".format(portnum, packet))
actions = None
for tnum,t i... | python | def _handle_datapath(self, inport, packet):
'''
Handle single packet on the data plane.
'''
inport = self._switchyard_net.port_by_name(inport)
portnum = inport.ifnum
log_info("Processing packet: {}->{}".format(portnum, packet))
actions = None
for tnum,t i... | [
"def",
"_handle_datapath",
"(",
"self",
",",
"inport",
",",
"packet",
")",
":",
"inport",
"=",
"self",
".",
"_switchyard_net",
".",
"port_by_name",
"(",
"inport",
")",
"portnum",
"=",
"inport",
".",
"ifnum",
"log_info",
"(",
"\"Processing packet: {}->{}\"",
".... | Handle single packet on the data plane. | [
"Handle",
"single",
"packet",
"on",
"the",
"data",
"plane",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/openflow/ofswitch.py#L538-L562 |
43,535 | jsommers/switchyard | switchyard/lib/packet/tcp.py | TCP.to_bytes | def to_bytes(self):
'''
Return packed byte representation of the TCP header.
'''
header = self._make_header(self._checksum)
return header + self._options.to_bytes() | python | def to_bytes(self):
'''
Return packed byte representation of the TCP header.
'''
header = self._make_header(self._checksum)
return header + self._options.to_bytes() | [
"def",
"to_bytes",
"(",
"self",
")",
":",
"header",
"=",
"self",
".",
"_make_header",
"(",
"self",
".",
"_checksum",
")",
"return",
"header",
"+",
"self",
".",
"_options",
".",
"to_bytes",
"(",
")"
] | Return packed byte representation of the TCP header. | [
"Return",
"packed",
"byte",
"representation",
"of",
"the",
"TCP",
"header",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/tcp.py#L110-L115 |
43,536 | jsommers/switchyard | switchyard/lib/address/__init__.py | infer_netmask | def infer_netmask (addr):
"""
Uses network classes to guess the number of network bits
"""
addr = int(addr)
if addr == 0:
# Special case -- default network
return 32-32 # all bits wildcarded
if (addr & (1 << 31)) == 0:
# Class A
return 32-24
if (addr & (3 << 30)) == 2 << 30:
# Class B
... | python | def infer_netmask (addr):
"""
Uses network classes to guess the number of network bits
"""
addr = int(addr)
if addr == 0:
# Special case -- default network
return 32-32 # all bits wildcarded
if (addr & (1 << 31)) == 0:
# Class A
return 32-24
if (addr & (3 << 30)) == 2 << 30:
# Class B
... | [
"def",
"infer_netmask",
"(",
"addr",
")",
":",
"addr",
"=",
"int",
"(",
"addr",
")",
"if",
"addr",
"==",
"0",
":",
"# Special case -- default network",
"return",
"32",
"-",
"32",
"# all bits wildcarded",
"if",
"(",
"addr",
"&",
"(",
"1",
"<<",
"31",
")",... | Uses network classes to guess the number of network bits | [
"Uses",
"network",
"classes",
"to",
"guess",
"the",
"number",
"of",
"network",
"bits"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/address/__init__.py#L266-L287 |
43,537 | jsommers/switchyard | switchyard/lib/address/__init__.py | EthAddr.isBridgeFiltered | def isBridgeFiltered (self):
"""
Checks if address is an IEEE 802.1D MAC Bridge Filtered MAC Group Address
This range is 01-80-C2-00-00-00 to 01-80-C2-00-00-0F. MAC frames that
have a destination MAC address within this range are not relayed by
bridges conforming to IEEE 802.1D
... | python | def isBridgeFiltered (self):
"""
Checks if address is an IEEE 802.1D MAC Bridge Filtered MAC Group Address
This range is 01-80-C2-00-00-00 to 01-80-C2-00-00-0F. MAC frames that
have a destination MAC address within this range are not relayed by
bridges conforming to IEEE 802.1D
... | [
"def",
"isBridgeFiltered",
"(",
"self",
")",
":",
"return",
"(",
"(",
"self",
".",
"__value",
"[",
"0",
"]",
"==",
"0x01",
")",
"and",
"(",
"self",
".",
"__value",
"[",
"1",
"]",
"==",
"0x80",
")",
"and",
"(",
"self",
".",
"__value",
"[",
"2",
... | Checks if address is an IEEE 802.1D MAC Bridge Filtered MAC Group Address
This range is 01-80-C2-00-00-00 to 01-80-C2-00-00-0F. MAC frames that
have a destination MAC address within this range are not relayed by
bridges conforming to IEEE 802.1D | [
"Checks",
"if",
"address",
"is",
"an",
"IEEE",
"802",
".",
"1D",
"MAC",
"Bridge",
"Filtered",
"MAC",
"Group",
"Address"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/address/__init__.py#L59-L72 |
43,538 | jsommers/switchyard | switchyard/lib/address/__init__.py | EthAddr.toStr | def toStr (self, separator = ':'):
"""
Returns the address as string consisting of 12 hex chars separated
by separator.
"""
return separator.join(('{:02x}'.format(x) for x in self.__value)) | python | def toStr (self, separator = ':'):
"""
Returns the address as string consisting of 12 hex chars separated
by separator.
"""
return separator.join(('{:02x}'.format(x) for x in self.__value)) | [
"def",
"toStr",
"(",
"self",
",",
"separator",
"=",
"':'",
")",
":",
"return",
"separator",
".",
"join",
"(",
"(",
"'{:02x}'",
".",
"format",
"(",
"x",
")",
"for",
"x",
"in",
"self",
".",
"__value",
")",
")"
] | Returns the address as string consisting of 12 hex chars separated
by separator. | [
"Returns",
"the",
"address",
"as",
"string",
"consisting",
"of",
"12",
"hex",
"chars",
"separated",
"by",
"separator",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/address/__init__.py#L129-L134 |
43,539 | jsommers/switchyard | switchyard/lib/packet/ethernet.py | Ethernet.to_bytes | def to_bytes(self):
'''
Return packed byte representation of the Ethernet header.
'''
return struct.pack(Ethernet._PACKFMT, self._dst.packed,
self._src.packed, self._ethertype.value) | python | def to_bytes(self):
'''
Return packed byte representation of the Ethernet header.
'''
return struct.pack(Ethernet._PACKFMT, self._dst.packed,
self._src.packed, self._ethertype.value) | [
"def",
"to_bytes",
"(",
"self",
")",
":",
"return",
"struct",
".",
"pack",
"(",
"Ethernet",
".",
"_PACKFMT",
",",
"self",
".",
"_dst",
".",
"packed",
",",
"self",
".",
"_src",
".",
"packed",
",",
"self",
".",
"_ethertype",
".",
"value",
")"
] | Return packed byte representation of the Ethernet header. | [
"Return",
"packed",
"byte",
"representation",
"of",
"the",
"Ethernet",
"header",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/ethernet.py#L142-L147 |
43,540 | jsommers/switchyard | switchyard/lib/socket/socketemu.py | ApplicationLayer._init | def _init():
'''
Internal switchyard static initialization method.
'''
if ApplicationLayer._isinit:
return
ApplicationLayer._isinit = True
ApplicationLayer._to_app = {}
ApplicationLayer._from_app = Queue() | python | def _init():
'''
Internal switchyard static initialization method.
'''
if ApplicationLayer._isinit:
return
ApplicationLayer._isinit = True
ApplicationLayer._to_app = {}
ApplicationLayer._from_app = Queue() | [
"def",
"_init",
"(",
")",
":",
"if",
"ApplicationLayer",
".",
"_isinit",
":",
"return",
"ApplicationLayer",
".",
"_isinit",
"=",
"True",
"ApplicationLayer",
".",
"_to_app",
"=",
"{",
"}",
"ApplicationLayer",
".",
"_from_app",
"=",
"Queue",
"(",
")"
] | Internal switchyard static initialization method. | [
"Internal",
"switchyard",
"static",
"initialization",
"method",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/socket/socketemu.py#L104-L112 |
43,541 | jsommers/switchyard | switchyard/lib/socket/socketemu.py | ApplicationLayer.recv_from_app | def recv_from_app(timeout=_default_timeout):
'''
Called by a network stack implementer to receive application-layer
data for sending on to a remote location.
Can optionally take a timeout value. If no data are available,
raises NoPackets exception.
Returns a 2-tuple:... | python | def recv_from_app(timeout=_default_timeout):
'''
Called by a network stack implementer to receive application-layer
data for sending on to a remote location.
Can optionally take a timeout value. If no data are available,
raises NoPackets exception.
Returns a 2-tuple:... | [
"def",
"recv_from_app",
"(",
"timeout",
"=",
"_default_timeout",
")",
":",
"try",
":",
"return",
"ApplicationLayer",
".",
"_from_app",
".",
"get",
"(",
"timeout",
"=",
"timeout",
")",
"except",
"Empty",
":",
"pass",
"raise",
"NoPackets",
"(",
")"
] | Called by a network stack implementer to receive application-layer
data for sending on to a remote location.
Can optionally take a timeout value. If no data are available,
raises NoPackets exception.
Returns a 2-tuple: flowaddr and data.
The flowaddr consists of 5 items: pro... | [
"Called",
"by",
"a",
"network",
"stack",
"implementer",
"to",
"receive",
"application",
"-",
"layer",
"data",
"for",
"sending",
"on",
"to",
"a",
"remote",
"location",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/socket/socketemu.py#L122-L138 |
43,542 | jsommers/switchyard | switchyard/lib/socket/socketemu.py | ApplicationLayer.send_to_app | def send_to_app(proto, local_addr, remote_addr, data):
'''
Called by a network stack implementer to push application-layer
data "up" from the stack.
Arguments are protocol number, local_addr (a 2-tuple of IP address
and port), remote_addr (a 2-tuple of IP address and port), and ... | python | def send_to_app(proto, local_addr, remote_addr, data):
'''
Called by a network stack implementer to push application-layer
data "up" from the stack.
Arguments are protocol number, local_addr (a 2-tuple of IP address
and port), remote_addr (a 2-tuple of IP address and port), and ... | [
"def",
"send_to_app",
"(",
"proto",
",",
"local_addr",
",",
"remote_addr",
",",
"data",
")",
":",
"proto",
"=",
"IPProtocol",
"(",
"proto",
")",
"local_addr",
"=",
"_normalize_addrs",
"(",
"local_addr",
")",
"remote_addr",
"=",
"_normalize_addrs",
"(",
"remote... | Called by a network stack implementer to push application-layer
data "up" from the stack.
Arguments are protocol number, local_addr (a 2-tuple of IP address
and port), remote_addr (a 2-tuple of IP address and port), and the
message.
Returns True if a socket was found to which... | [
"Called",
"by",
"a",
"network",
"stack",
"implementer",
"to",
"push",
"application",
"-",
"layer",
"data",
"up",
"from",
"the",
"stack",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/socket/socketemu.py#L141-L175 |
43,543 | jsommers/switchyard | switchyard/lib/socket/socketemu.py | ApplicationLayer._registry_update | def _registry_update(s, oldid):
'''
Internal method used to update an existing socket registry when the socket
is re-bound to a different local port number. Requires the socket object
and old sockid. Returns None.
'''
with _lock:
sock_queue = ApplicationLaye... | python | def _registry_update(s, oldid):
'''
Internal method used to update an existing socket registry when the socket
is re-bound to a different local port number. Requires the socket object
and old sockid. Returns None.
'''
with _lock:
sock_queue = ApplicationLaye... | [
"def",
"_registry_update",
"(",
"s",
",",
"oldid",
")",
":",
"with",
"_lock",
":",
"sock_queue",
"=",
"ApplicationLayer",
".",
"_to_app",
".",
"pop",
"(",
"oldid",
")",
"ApplicationLayer",
".",
"_to_app",
"[",
"s",
".",
"_sockid",
"(",
")",
"]",
"=",
"... | Internal method used to update an existing socket registry when the socket
is re-bound to a different local port number. Requires the socket object
and old sockid. Returns None. | [
"Internal",
"method",
"used",
"to",
"update",
"an",
"existing",
"socket",
"registry",
"when",
"the",
"socket",
"is",
"re",
"-",
"bound",
"to",
"a",
"different",
"local",
"port",
"number",
".",
"Requires",
"the",
"socket",
"object",
"and",
"old",
"sockid",
... | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/socket/socketemu.py#L190-L198 |
43,544 | jsommers/switchyard | switchyard/lib/socket/socketemu.py | ApplicationLayer._unregister_socket | def _unregister_socket(s):
'''
Internal method used to remove the socket from AppLayer registry.
Warns if the "upward" socket queue has any left-over data.
'''
with _lock:
sock_queue = ApplicationLayer._to_app.pop(s._sockid())
if not sock_queue.empty():
... | python | def _unregister_socket(s):
'''
Internal method used to remove the socket from AppLayer registry.
Warns if the "upward" socket queue has any left-over data.
'''
with _lock:
sock_queue = ApplicationLayer._to_app.pop(s._sockid())
if not sock_queue.empty():
... | [
"def",
"_unregister_socket",
"(",
"s",
")",
":",
"with",
"_lock",
":",
"sock_queue",
"=",
"ApplicationLayer",
".",
"_to_app",
".",
"pop",
"(",
"s",
".",
"_sockid",
"(",
")",
")",
"if",
"not",
"sock_queue",
".",
"empty",
"(",
")",
":",
"log_warn",
"(",
... | Internal method used to remove the socket from AppLayer registry.
Warns if the "upward" socket queue has any left-over data. | [
"Internal",
"method",
"used",
"to",
"remove",
"the",
"socket",
"from",
"AppLayer",
"registry",
".",
"Warns",
"if",
"the",
"upward",
"socket",
"queue",
"has",
"any",
"left",
"-",
"over",
"data",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/socket/socketemu.py#L201-L209 |
43,545 | jsommers/switchyard | switchyard/lib/socket/socketemu.py | socket.bind | def bind(self, address):
'''
Alter the local address with which this socket is associated.
The address parameter is a 2-tuple consisting of an IP address
and port number.
NB: this method fails and returns -1 if the requested port
to bind to is already in use but does *n... | python | def bind(self, address):
'''
Alter the local address with which this socket is associated.
The address parameter is a 2-tuple consisting of an IP address
and port number.
NB: this method fails and returns -1 if the requested port
to bind to is already in use but does *n... | [
"def",
"bind",
"(",
"self",
",",
"address",
")",
":",
"portset",
"=",
"_gather_ports",
"(",
")",
".",
"union",
"(",
"ApplicationLayer",
".",
"_emuports",
"(",
")",
")",
"if",
"address",
"[",
"1",
"]",
"in",
"portset",
":",
"log_warn",
"(",
"\"Port is a... | Alter the local address with which this socket is associated.
The address parameter is a 2-tuple consisting of an IP address
and port number.
NB: this method fails and returns -1 if the requested port
to bind to is already in use but does *not* check that the
address is valid. | [
"Alter",
"the",
"local",
"address",
"with",
"which",
"this",
"socket",
"is",
"associated",
".",
"The",
"address",
"parameter",
"is",
"a",
"2",
"-",
"tuple",
"consisting",
"of",
"an",
"IP",
"address",
"and",
"port",
"number",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/socket/socketemu.py#L314-L336 |
43,546 | jsommers/switchyard | switchyard/lib/socket/socketemu.py | socket.recv | def recv(self, buffersize, flags=0):
'''
Receive data on the socket. The buffersize and flags
arguments are currently ignored. Only returns the data.
'''
_,_,data = self._recv(buffersize)
return data | python | def recv(self, buffersize, flags=0):
'''
Receive data on the socket. The buffersize and flags
arguments are currently ignored. Only returns the data.
'''
_,_,data = self._recv(buffersize)
return data | [
"def",
"recv",
"(",
"self",
",",
"buffersize",
",",
"flags",
"=",
"0",
")",
":",
"_",
",",
"_",
",",
"data",
"=",
"self",
".",
"_recv",
"(",
"buffersize",
")",
"return",
"data"
] | Receive data on the socket. The buffersize and flags
arguments are currently ignored. Only returns the data. | [
"Receive",
"data",
"on",
"the",
"socket",
".",
"The",
"buffersize",
"and",
"flags",
"arguments",
"are",
"currently",
"ignored",
".",
"Only",
"returns",
"the",
"data",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/socket/socketemu.py#L393-L399 |
43,547 | jsommers/switchyard | switchyard/lib/socket/socketemu.py | socket.settimeout | def settimeout(self, timeout):
'''
Set the timeout value for this socket.
'''
if timeout is None:
self._block = True
elif float(timeout) == 0.0:
self._block = False
else:
self._timeout = float(timeout)
self._block = True | python | def settimeout(self, timeout):
'''
Set the timeout value for this socket.
'''
if timeout is None:
self._block = True
elif float(timeout) == 0.0:
self._block = False
else:
self._timeout = float(timeout)
self._block = True | [
"def",
"settimeout",
"(",
"self",
",",
"timeout",
")",
":",
"if",
"timeout",
"is",
"None",
":",
"self",
".",
"_block",
"=",
"True",
"elif",
"float",
"(",
"timeout",
")",
"==",
"0.0",
":",
"self",
".",
"_block",
"=",
"False",
"else",
":",
"self",
".... | Set the timeout value for this socket. | [
"Set",
"the",
"timeout",
"value",
"for",
"this",
"socket",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/socket/socketemu.py#L487-L497 |
43,548 | jsommers/switchyard | switchyard/lib/packet/arp.py | Arp.to_bytes | def to_bytes(self):
'''
Return packed byte representation of the ARP header.
'''
return struct.pack(Arp._PACKFMT, self._hwtype.value, self._prototype.value, self._hwaddrlen, self._protoaddrlen, self._operation.value, self._senderhwaddr.packed, self._senderprotoaddr.packed, self._targethw... | python | def to_bytes(self):
'''
Return packed byte representation of the ARP header.
'''
return struct.pack(Arp._PACKFMT, self._hwtype.value, self._prototype.value, self._hwaddrlen, self._protoaddrlen, self._operation.value, self._senderhwaddr.packed, self._senderprotoaddr.packed, self._targethw... | [
"def",
"to_bytes",
"(",
"self",
")",
":",
"return",
"struct",
".",
"pack",
"(",
"Arp",
".",
"_PACKFMT",
",",
"self",
".",
"_hwtype",
".",
"value",
",",
"self",
".",
"_prototype",
".",
"value",
",",
"self",
".",
"_hwaddrlen",
",",
"self",
".",
"_proto... | Return packed byte representation of the ARP header. | [
"Return",
"packed",
"byte",
"representation",
"of",
"the",
"ARP",
"header",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/arp.py#L41-L45 |
43,549 | bronto/javasphinx | javasphinx/htmlrst.py | Converter._process_table_cells | def _process_table_cells(self, table):
""" Compile all the table cells.
Returns a list of rows. The rows may have different lengths because of
column spans.
"""
rows = []
for i, tr in enumerate(table.find_all('tr')):
row = []
for c in tr.conte... | python | def _process_table_cells(self, table):
""" Compile all the table cells.
Returns a list of rows. The rows may have different lengths because of
column spans.
"""
rows = []
for i, tr in enumerate(table.find_all('tr')):
row = []
for c in tr.conte... | [
"def",
"_process_table_cells",
"(",
"self",
",",
"table",
")",
":",
"rows",
"=",
"[",
"]",
"for",
"i",
",",
"tr",
"in",
"enumerate",
"(",
"table",
".",
"find_all",
"(",
"'tr'",
")",
")",
":",
"row",
"=",
"[",
"]",
"for",
"c",
"in",
"tr",
".",
"... | Compile all the table cells.
Returns a list of rows. The rows may have different lengths because of
column spans. | [
"Compile",
"all",
"the",
"table",
"cells",
"."
] | cd1df27f1d70efaae079b74573efdd8e069ff02d | https://github.com/bronto/javasphinx/blob/cd1df27f1d70efaae079b74573efdd8e069ff02d/javasphinx/htmlrst.py#L118-L148 |
43,550 | jsommers/switchyard | switchyard/importcode.py | import_or_die | def import_or_die(module_name, entrypoint_names):
'''
Import user code; return reference to usercode function.
(str) -> function reference
'''
log_debug("Importing {}".format(module_name))
module_name = os.path.abspath(module_name)
if module_name.endswith('.py'):
module_name,ext = o... | python | def import_or_die(module_name, entrypoint_names):
'''
Import user code; return reference to usercode function.
(str) -> function reference
'''
log_debug("Importing {}".format(module_name))
module_name = os.path.abspath(module_name)
if module_name.endswith('.py'):
module_name,ext = o... | [
"def",
"import_or_die",
"(",
"module_name",
",",
"entrypoint_names",
")",
":",
"log_debug",
"(",
"\"Importing {}\"",
".",
"format",
"(",
"module_name",
")",
")",
"module_name",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"module_name",
")",
"if",
"module_name... | Import user code; return reference to usercode function.
(str) -> function reference | [
"Import",
"user",
"code",
";",
"return",
"reference",
"to",
"usercode",
"function",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/importcode.py#L7-L52 |
43,551 | jsommers/switchyard | switchyard/hostfirewall.py | _runcmd | def _runcmd(progargs, stdinput=None):
'''
Run the command progargs with optional input to be fed in to stdin.
'''
stdin = None
if stdinput is not None:
assert(isinstance(stdinput, list))
stdin=PIPE
err = 0
output = b''
log_debug("Calling {} with input {}".format(' '.join... | python | def _runcmd(progargs, stdinput=None):
'''
Run the command progargs with optional input to be fed in to stdin.
'''
stdin = None
if stdinput is not None:
assert(isinstance(stdinput, list))
stdin=PIPE
err = 0
output = b''
log_debug("Calling {} with input {}".format(' '.join... | [
"def",
"_runcmd",
"(",
"progargs",
",",
"stdinput",
"=",
"None",
")",
":",
"stdin",
"=",
"None",
"if",
"stdinput",
"is",
"not",
"None",
":",
"assert",
"(",
"isinstance",
"(",
"stdinput",
",",
"list",
")",
")",
"stdin",
"=",
"PIPE",
"err",
"=",
"0",
... | Run the command progargs with optional input to be fed in to stdin. | [
"Run",
"the",
"command",
"progargs",
"with",
"optional",
"input",
"to",
"be",
"fed",
"in",
"to",
"stdin",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/hostfirewall.py#L17-L47 |
43,552 | jsommers/switchyard | switchyard/hostfirewall.py | MacOSFirewall.block | def block(self):
'''
pfctl -a switchyard -f- < rules.txt
pfctl -a switchyard -F rules
pfctl -t switchyard -F r
'''
st,output = _runcmd("/sbin/pfctl -aswitchyard -f -", self._rules)
log_debug("Installing rules: {}".format(output)) | python | def block(self):
'''
pfctl -a switchyard -f- < rules.txt
pfctl -a switchyard -F rules
pfctl -t switchyard -F r
'''
st,output = _runcmd("/sbin/pfctl -aswitchyard -f -", self._rules)
log_debug("Installing rules: {}".format(output)) | [
"def",
"block",
"(",
"self",
")",
":",
"st",
",",
"output",
"=",
"_runcmd",
"(",
"\"/sbin/pfctl -aswitchyard -f -\"",
",",
"self",
".",
"_rules",
")",
"log_debug",
"(",
"\"Installing rules: {}\"",
".",
"format",
"(",
"output",
")",
")"
] | pfctl -a switchyard -f- < rules.txt
pfctl -a switchyard -F rules
pfctl -t switchyard -F r | [
"pfctl",
"-",
"a",
"switchyard",
"-",
"f",
"-",
"<",
"rules",
".",
"txt",
"pfctl",
"-",
"a",
"switchyard",
"-",
"F",
"rules",
"pfctl",
"-",
"t",
"switchyard",
"-",
"F",
"r"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/hostfirewall.py#L252-L259 |
43,553 | jsommers/switchyard | switchyard/lib/topo/topobuild.py | show_graph | def show_graph(cn_topo, showintfs=False, showaddrs=False):
'''
Display the topology
'''
__do_draw(cn_topo, showintfs=showintfs, showaddrs=showaddrs)
pyp.show() | python | def show_graph(cn_topo, showintfs=False, showaddrs=False):
'''
Display the topology
'''
__do_draw(cn_topo, showintfs=showintfs, showaddrs=showaddrs)
pyp.show() | [
"def",
"show_graph",
"(",
"cn_topo",
",",
"showintfs",
"=",
"False",
",",
"showaddrs",
"=",
"False",
")",
":",
"__do_draw",
"(",
"cn_topo",
",",
"showintfs",
"=",
"showintfs",
",",
"showaddrs",
"=",
"showaddrs",
")",
"pyp",
".",
"show",
"(",
")"
] | Display the topology | [
"Display",
"the",
"topology"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L436-L441 |
43,554 | jsommers/switchyard | switchyard/lib/topo/topobuild.py | save_graph | def save_graph(cn_topo, filename, showintfs=False, showaddrs=False):
'''
Save the topology to an image file
'''
__do_draw(cn_topo, showintfs=showintfs, showaddrs=showaddrs)
pyp.savefig(filename) | python | def save_graph(cn_topo, filename, showintfs=False, showaddrs=False):
'''
Save the topology to an image file
'''
__do_draw(cn_topo, showintfs=showintfs, showaddrs=showaddrs)
pyp.savefig(filename) | [
"def",
"save_graph",
"(",
"cn_topo",
",",
"filename",
",",
"showintfs",
"=",
"False",
",",
"showaddrs",
"=",
"False",
")",
":",
"__do_draw",
"(",
"cn_topo",
",",
"showintfs",
"=",
"showintfs",
",",
"showaddrs",
"=",
"showaddrs",
")",
"pyp",
".",
"savefig",... | Save the topology to an image file | [
"Save",
"the",
"topology",
"to",
"an",
"image",
"file"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L443-L448 |
43,555 | jsommers/switchyard | switchyard/lib/topo/topobuild.py | load_from_file | def load_from_file(filename):
'''
Load a topology from filename and return it.
'''
t = None
with open(filename, 'rU') as infile:
tdata = infile.read()
t = Topology.unserialize(tdata)
return t | python | def load_from_file(filename):
'''
Load a topology from filename and return it.
'''
t = None
with open(filename, 'rU') as infile:
tdata = infile.read()
t = Topology.unserialize(tdata)
return t | [
"def",
"load_from_file",
"(",
"filename",
")",
":",
"t",
"=",
"None",
"with",
"open",
"(",
"filename",
",",
"'rU'",
")",
"as",
"infile",
":",
"tdata",
"=",
"infile",
".",
"read",
"(",
")",
"t",
"=",
"Topology",
".",
"unserialize",
"(",
"tdata",
")",
... | Load a topology from filename and return it. | [
"Load",
"a",
"topology",
"from",
"filename",
"and",
"return",
"it",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L450-L458 |
43,556 | jsommers/switchyard | switchyard/lib/topo/topobuild.py | save_to_file | def save_to_file(cn_topo, filename):
'''
Save a topology to a file.
'''
jstr = cn_topo.serialize()
with open(filename, 'w') as outfile:
outfile.write(jstr) | python | def save_to_file(cn_topo, filename):
'''
Save a topology to a file.
'''
jstr = cn_topo.serialize()
with open(filename, 'w') as outfile:
outfile.write(jstr) | [
"def",
"save_to_file",
"(",
"cn_topo",
",",
"filename",
")",
":",
"jstr",
"=",
"cn_topo",
".",
"serialize",
"(",
")",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"outfile",
":",
"outfile",
".",
"write",
"(",
"jstr",
")"
] | Save a topology to a file. | [
"Save",
"a",
"topology",
"to",
"a",
"file",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L460-L466 |
43,557 | jsommers/switchyard | switchyard/lib/topo/topobuild.py | Topology.__addNode | def __addNode(self, name, cls):
'''
Add a node to the topology
'''
if name in self.nodes:
raise Exception("A node by the name {} already exists. Can't add a duplicate.".format(name))
self.__nxgraph.add_node(name)
self.__nxgraph.node[name]['label'] = name
... | python | def __addNode(self, name, cls):
'''
Add a node to the topology
'''
if name in self.nodes:
raise Exception("A node by the name {} already exists. Can't add a duplicate.".format(name))
self.__nxgraph.add_node(name)
self.__nxgraph.node[name]['label'] = name
... | [
"def",
"__addNode",
"(",
"self",
",",
"name",
",",
"cls",
")",
":",
"if",
"name",
"in",
"self",
".",
"nodes",
":",
"raise",
"Exception",
"(",
"\"A node by the name {} already exists. Can't add a duplicate.\"",
".",
"format",
"(",
"name",
")",
")",
"self",
"."... | Add a node to the topology | [
"Add",
"a",
"node",
"to",
"the",
"topology"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L122-L131 |
43,558 | jsommers/switchyard | switchyard/lib/topo/topobuild.py | Topology.addHost | def addHost(self, name=None):
'''
Add a new host node to the topology.
'''
if name is None:
while True:
name = 'h' + str(self.__hnum)
self.__hnum += 1
if name not in self.__nxgraph:
break
self.__addNo... | python | def addHost(self, name=None):
'''
Add a new host node to the topology.
'''
if name is None:
while True:
name = 'h' + str(self.__hnum)
self.__hnum += 1
if name not in self.__nxgraph:
break
self.__addNo... | [
"def",
"addHost",
"(",
"self",
",",
"name",
"=",
"None",
")",
":",
"if",
"name",
"is",
"None",
":",
"while",
"True",
":",
"name",
"=",
"'h'",
"+",
"str",
"(",
"self",
".",
"__hnum",
")",
"self",
".",
"__hnum",
"+=",
"1",
"if",
"name",
"not",
"i... | Add a new host node to the topology. | [
"Add",
"a",
"new",
"host",
"node",
"to",
"the",
"topology",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L173-L184 |
43,559 | jsommers/switchyard | switchyard/lib/topo/topobuild.py | Topology.addLink | def addLink(self, node1, node2, capacity, delay):
'''
Add a bidirectional link between node1 and node2 with the given
capacity and delay to the topology.
'''
for n in (node1, node2):
if not self.__nxgraph.has_node(n):
raise Exception("No node {} exists... | python | def addLink(self, node1, node2, capacity, delay):
'''
Add a bidirectional link between node1 and node2 with the given
capacity and delay to the topology.
'''
for n in (node1, node2):
if not self.__nxgraph.has_node(n):
raise Exception("No node {} exists... | [
"def",
"addLink",
"(",
"self",
",",
"node1",
",",
"node2",
",",
"capacity",
",",
"delay",
")",
":",
"for",
"n",
"in",
"(",
"node1",
",",
"node2",
")",
":",
"if",
"not",
"self",
".",
"__nxgraph",
".",
"has_node",
"(",
"n",
")",
":",
"raise",
"Exce... | Add a bidirectional link between node1 and node2 with the given
capacity and delay to the topology. | [
"Add",
"a",
"bidirectional",
"link",
"between",
"node1",
"and",
"node2",
"with",
"the",
"given",
"capacity",
"and",
"delay",
"to",
"the",
"topology",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L231-L251 |
43,560 | jsommers/switchyard | switchyard/lib/topo/topobuild.py | Topology.serialize | def serialize(self):
'''
Return a JSON string of the serialized topology
'''
return json.dumps(json_graph.node_link_data(self.__nxgraph), cls=Encoder) | python | def serialize(self):
'''
Return a JSON string of the serialized topology
'''
return json.dumps(json_graph.node_link_data(self.__nxgraph), cls=Encoder) | [
"def",
"serialize",
"(",
"self",
")",
":",
"return",
"json",
".",
"dumps",
"(",
"json_graph",
".",
"node_link_data",
"(",
"self",
".",
"__nxgraph",
")",
",",
"cls",
"=",
"Encoder",
")"
] | Return a JSON string of the serialized topology | [
"Return",
"a",
"JSON",
"string",
"of",
"the",
"serialized",
"topology"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L266-L270 |
43,561 | jsommers/switchyard | switchyard/lib/topo/topobuild.py | Topology.unserialize | def unserialize(jsonstr):
'''
Unserialize a JSON string representation of a topology
'''
topod = json.loads(jsonstr)
G = json_graph.node_link_graph(topod)
for n,ndict in G.nodes(data=True):
if 'nodeobj' not in ndict or 'type' not in ndict:
rais... | python | def unserialize(jsonstr):
'''
Unserialize a JSON string representation of a topology
'''
topod = json.loads(jsonstr)
G = json_graph.node_link_graph(topod)
for n,ndict in G.nodes(data=True):
if 'nodeobj' not in ndict or 'type' not in ndict:
rais... | [
"def",
"unserialize",
"(",
"jsonstr",
")",
":",
"topod",
"=",
"json",
".",
"loads",
"(",
"jsonstr",
")",
"G",
"=",
"json_graph",
".",
"node_link_graph",
"(",
"topod",
")",
"for",
"n",
",",
"ndict",
"in",
"G",
".",
"nodes",
"(",
"data",
"=",
"True",
... | Unserialize a JSON string representation of a topology | [
"Unserialize",
"a",
"JSON",
"string",
"representation",
"of",
"a",
"topology"
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L273-L286 |
43,562 | jsommers/switchyard | switchyard/lib/topo/topobuild.py | Topology.getInterfaceAddresses | def getInterfaceAddresses(self, node, interface):
'''
Return the Ethernet and IP+mask addresses assigned to a
given interface on a node.
'''
intf = self.getNode(node)['nodeobj'].getInterface(interface)
return intf.ethaddr,intf.ipaddr,intf.netmask | python | def getInterfaceAddresses(self, node, interface):
'''
Return the Ethernet and IP+mask addresses assigned to a
given interface on a node.
'''
intf = self.getNode(node)['nodeobj'].getInterface(interface)
return intf.ethaddr,intf.ipaddr,intf.netmask | [
"def",
"getInterfaceAddresses",
"(",
"self",
",",
"node",
",",
"interface",
")",
":",
"intf",
"=",
"self",
".",
"getNode",
"(",
"node",
")",
"[",
"'nodeobj'",
"]",
".",
"getInterface",
"(",
"interface",
")",
"return",
"intf",
".",
"ethaddr",
",",
"intf",... | Return the Ethernet and IP+mask addresses assigned to a
given interface on a node. | [
"Return",
"the",
"Ethernet",
"and",
"IP",
"+",
"mask",
"addresses",
"assigned",
"to",
"a",
"given",
"interface",
"on",
"a",
"node",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L348-L354 |
43,563 | jsommers/switchyard | switchyard/lib/topo/topobuild.py | Topology.addNodeLabelPrefix | def addNodeLabelPrefix(self, prefix=None, copy=False):
'''
Rename all nodes in the network from x to prefix_x. If no prefix
is given, use the name of the graph as the prefix.
The purpose of this method is to make node names unique so that
composing two graphs is well-de... | python | def addNodeLabelPrefix(self, prefix=None, copy=False):
'''
Rename all nodes in the network from x to prefix_x. If no prefix
is given, use the name of the graph as the prefix.
The purpose of this method is to make node names unique so that
composing two graphs is well-de... | [
"def",
"addNodeLabelPrefix",
"(",
"self",
",",
"prefix",
"=",
"None",
",",
"copy",
"=",
"False",
")",
":",
"nxgraph",
"=",
"Topology",
".",
"__relabel_graph",
"(",
"self",
".",
"__nxgraph",
",",
"prefix",
")",
"if",
"copy",
":",
"newtopo",
"=",
"copy",
... | Rename all nodes in the network from x to prefix_x. If no prefix
is given, use the name of the graph as the prefix.
The purpose of this method is to make node names unique so that
composing two graphs is well-defined. | [
"Rename",
"all",
"nodes",
"in",
"the",
"network",
"from",
"x",
"to",
"prefix_x",
".",
"If",
"no",
"prefix",
"is",
"given",
"use",
"the",
"name",
"of",
"the",
"graph",
"as",
"the",
"prefix",
".",
"The",
"purpose",
"of",
"this",
"method",
"is",
"to",
"... | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/topo/topobuild.py#L376-L391 |
43,564 | jsommers/switchyard | switchyard/lib/packet/null.py | Null.from_bytes | def from_bytes(self, raw):
'''Return a Null header object reconstructed from raw bytes, or an
Exception if we can't resurrect the packet.'''
if len(raw) < 4:
raise NotEnoughDataError("Not enough bytes ({}) to reconstruct a Null object".format(len(raw)))
fields = struct.unpack... | python | def from_bytes(self, raw):
'''Return a Null header object reconstructed from raw bytes, or an
Exception if we can't resurrect the packet.'''
if len(raw) < 4:
raise NotEnoughDataError("Not enough bytes ({}) to reconstruct a Null object".format(len(raw)))
fields = struct.unpack... | [
"def",
"from_bytes",
"(",
"self",
",",
"raw",
")",
":",
"if",
"len",
"(",
"raw",
")",
"<",
"4",
":",
"raise",
"NotEnoughDataError",
"(",
"\"Not enough bytes ({}) to reconstruct a Null object\"",
".",
"format",
"(",
"len",
"(",
"raw",
")",
")",
")",
"fields",... | Return a Null header object reconstructed from raw bytes, or an
Exception if we can't resurrect the packet. | [
"Return",
"a",
"Null",
"header",
"object",
"reconstructed",
"from",
"raw",
"bytes",
"or",
"an",
"Exception",
"if",
"we",
"can",
"t",
"resurrect",
"the",
"packet",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/null.py#L43-L50 |
43,565 | jsommers/switchyard | switchyard/lib/packet/packet.py | Packet.add_header | def add_header(self, ph):
'''
Add a PacketHeaderBase derived class object, or a raw bytes object
as the next "header" item in this packet. Note that 'header'
may be a slight misnomer since the last portion of a packet is
considered application payload and not a header per se.
... | python | def add_header(self, ph):
'''
Add a PacketHeaderBase derived class object, or a raw bytes object
as the next "header" item in this packet. Note that 'header'
may be a slight misnomer since the last portion of a packet is
considered application payload and not a header per se.
... | [
"def",
"add_header",
"(",
"self",
",",
"ph",
")",
":",
"if",
"isinstance",
"(",
"ph",
",",
"bytes",
")",
":",
"ph",
"=",
"RawPacketContents",
"(",
"ph",
")",
"if",
"isinstance",
"(",
"ph",
",",
"PacketHeaderBase",
")",
":",
"self",
".",
"_headers",
"... | Add a PacketHeaderBase derived class object, or a raw bytes object
as the next "header" item in this packet. Note that 'header'
may be a slight misnomer since the last portion of a packet is
considered application payload and not a header per se. | [
"Add",
"a",
"PacketHeaderBase",
"derived",
"class",
"object",
"or",
"a",
"raw",
"bytes",
"object",
"as",
"the",
"next",
"header",
"item",
"in",
"this",
"packet",
".",
"Note",
"that",
"header",
"may",
"be",
"a",
"slight",
"misnomer",
"since",
"the",
"last",... | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/packet.py#L109-L121 |
43,566 | jsommers/switchyard | switchyard/lib/packet/packet.py | Packet.has_header | def has_header(self, hdrclass):
'''
Return True if the packet has a header of the given hdrclass,
False otherwise.
'''
if isinstance(hdrclass, str):
return self.get_header_by_name(hdrclass) is not None
return self.get_header(hdrclass) is not None | python | def has_header(self, hdrclass):
'''
Return True if the packet has a header of the given hdrclass,
False otherwise.
'''
if isinstance(hdrclass, str):
return self.get_header_by_name(hdrclass) is not None
return self.get_header(hdrclass) is not None | [
"def",
"has_header",
"(",
"self",
",",
"hdrclass",
")",
":",
"if",
"isinstance",
"(",
"hdrclass",
",",
"str",
")",
":",
"return",
"self",
".",
"get_header_by_name",
"(",
"hdrclass",
")",
"is",
"not",
"None",
"return",
"self",
".",
"get_header",
"(",
"hdr... | Return True if the packet has a header of the given hdrclass,
False otherwise. | [
"Return",
"True",
"if",
"the",
"packet",
"has",
"a",
"header",
"of",
"the",
"given",
"hdrclass",
"False",
"otherwise",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/packet.py#L135-L142 |
43,567 | jsommers/switchyard | switchyard/lib/packet/packet.py | Packet.get_header | def get_header(self, hdrclass, returnval=None):
'''
Return the first header object that is of
class hdrclass, or None if the header class isn't
found.
'''
if isinstance(hdrclass, str):
return self.get_header_by_name(hdrclass)
for hdr in self._headers:... | python | def get_header(self, hdrclass, returnval=None):
'''
Return the first header object that is of
class hdrclass, or None if the header class isn't
found.
'''
if isinstance(hdrclass, str):
return self.get_header_by_name(hdrclass)
for hdr in self._headers:... | [
"def",
"get_header",
"(",
"self",
",",
"hdrclass",
",",
"returnval",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"hdrclass",
",",
"str",
")",
":",
"return",
"self",
".",
"get_header_by_name",
"(",
"hdrclass",
")",
"for",
"hdr",
"in",
"self",
".",
"... | Return the first header object that is of
class hdrclass, or None if the header class isn't
found. | [
"Return",
"the",
"first",
"header",
"object",
"that",
"is",
"of",
"class",
"hdrclass",
"or",
"None",
"if",
"the",
"header",
"class",
"isn",
"t",
"found",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/packet.py#L154-L166 |
43,568 | jsommers/switchyard | switchyard/lib/packet/packet.py | PacketHeaderBase.next_header_class | def next_header_class(self):
'''Return class of next header, if known.'''
if self._next_header_class_key == '':
return None
key = getattr(self, self._next_header_class_key)
rv = self._next_header_map.get(key, None)
if rv is None:
log_warn("No class exists ... | python | def next_header_class(self):
'''Return class of next header, if known.'''
if self._next_header_class_key == '':
return None
key = getattr(self, self._next_header_class_key)
rv = self._next_header_map.get(key, None)
if rv is None:
log_warn("No class exists ... | [
"def",
"next_header_class",
"(",
"self",
")",
":",
"if",
"self",
".",
"_next_header_class_key",
"==",
"''",
":",
"return",
"None",
"key",
"=",
"getattr",
"(",
"self",
",",
"self",
".",
"_next_header_class_key",
")",
"rv",
"=",
"self",
".",
"_next_header_map"... | Return class of next header, if known. | [
"Return",
"class",
"of",
"next",
"header",
"if",
"known",
"."
] | fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0 | https://github.com/jsommers/switchyard/blob/fdcb3869c937dcedbd6ea7a7822ebd412bf1e2b0/switchyard/lib/packet/packet.py#L285-L293 |
43,569 | jlmadurga/permabots | permabots/views/hooks/messenger_hook.py | MessengerHookView.get | def get(self, request, hook_id):
"""
Verify token when configuring webhook from facebook dev.
MessengerBot.id is used for verification
"""
try:
bot = caching.get_or_set(MessengerBot, hook_id)
except MessengerBot.DoesNotExist:
logger.warnin... | python | def get(self, request, hook_id):
"""
Verify token when configuring webhook from facebook dev.
MessengerBot.id is used for verification
"""
try:
bot = caching.get_or_set(MessengerBot, hook_id)
except MessengerBot.DoesNotExist:
logger.warnin... | [
"def",
"get",
"(",
"self",
",",
"request",
",",
"hook_id",
")",
":",
"try",
":",
"bot",
"=",
"caching",
".",
"get_or_set",
"(",
"MessengerBot",
",",
"hook_id",
")",
"except",
"MessengerBot",
".",
"DoesNotExist",
":",
"logger",
".",
"warning",
"(",
"\"Hoo... | Verify token when configuring webhook from facebook dev.
MessengerBot.id is used for verification | [
"Verify",
"token",
"when",
"configuring",
"webhook",
"from",
"facebook",
"dev",
".",
"MessengerBot",
".",
"id",
"is",
"used",
"for",
"verification"
] | 781a91702529a23fe7bc2aa84c5d88e961412466 | https://github.com/jlmadurga/permabots/blob/781a91702529a23fe7bc2aa84c5d88e961412466/permabots/views/hooks/messenger_hook.py#L183-L196 |
43,570 | tutorcruncher/django-bootstrap3-datetimepicker | bootstrap3_datetime/widgets.py | DateTimePicker._format_value | def _format_value(self, value):
"""This function name was changed in Django 1.10 and removed in 2.0."""
# Use renamed format_name() for Django versions >= 1.10.
if hasattr(self, 'format_value'):
return super(DateTimePicker, self).format_value(value)
# Use old _format_name() f... | python | def _format_value(self, value):
"""This function name was changed in Django 1.10 and removed in 2.0."""
# Use renamed format_name() for Django versions >= 1.10.
if hasattr(self, 'format_value'):
return super(DateTimePicker, self).format_value(value)
# Use old _format_name() f... | [
"def",
"_format_value",
"(",
"self",
",",
"value",
")",
":",
"# Use renamed format_name() for Django versions >= 1.10.",
"if",
"hasattr",
"(",
"self",
",",
"'format_value'",
")",
":",
"return",
"super",
"(",
"DateTimePicker",
",",
"self",
")",
".",
"format_value",
... | This function name was changed in Django 1.10 and removed in 2.0. | [
"This",
"function",
"name",
"was",
"changed",
"in",
"Django",
"1",
".",
"10",
"and",
"removed",
"in",
"2",
".",
"0",
"."
] | 21ee9245116e1a3424e8d9d751446b5651cb6441 | https://github.com/tutorcruncher/django-bootstrap3-datetimepicker/blob/21ee9245116e1a3424e8d9d751446b5651cb6441/bootstrap3_datetime/widgets.py#L84-L91 |
43,571 | campaignmonitor/createsend-python | lib/createsend/createsend.py | CreateSendBase.authorize_url | def authorize_url(self, client_id, redirect_uri, scope, state=None):
"""Get the authorization URL for your application, given the application's
client_id, redirect_uri, scope, and optional state data."""
params = [
('client_id', client_id),
('redirect_uri', redirect_uri),... | python | def authorize_url(self, client_id, redirect_uri, scope, state=None):
"""Get the authorization URL for your application, given the application's
client_id, redirect_uri, scope, and optional state data."""
params = [
('client_id', client_id),
('redirect_uri', redirect_uri),... | [
"def",
"authorize_url",
"(",
"self",
",",
"client_id",
",",
"redirect_uri",
",",
"scope",
",",
"state",
"=",
"None",
")",
":",
"params",
"=",
"[",
"(",
"'client_id'",
",",
"client_id",
")",
",",
"(",
"'redirect_uri'",
",",
"redirect_uri",
")",
",",
"(",
... | Get the authorization URL for your application, given the application's
client_id, redirect_uri, scope, and optional state data. | [
"Get",
"the",
"authorization",
"URL",
"for",
"your",
"application",
"given",
"the",
"application",
"s",
"client_id",
"redirect_uri",
"scope",
"and",
"optional",
"state",
"data",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/createsend.py#L70-L80 |
43,572 | campaignmonitor/createsend-python | lib/createsend/createsend.py | CreateSendBase.exchange_token | def exchange_token(self, client_id, client_secret, redirect_uri, code):
"""Exchange a provided OAuth code for an OAuth access token, 'expires in'
value and refresh token."""
params = [
('grant_type', 'authorization_code'),
('client_id', client_id),
('client_se... | python | def exchange_token(self, client_id, client_secret, redirect_uri, code):
"""Exchange a provided OAuth code for an OAuth access token, 'expires in'
value and refresh token."""
params = [
('grant_type', 'authorization_code'),
('client_id', client_id),
('client_se... | [
"def",
"exchange_token",
"(",
"self",
",",
"client_id",
",",
"client_secret",
",",
"redirect_uri",
",",
"code",
")",
":",
"params",
"=",
"[",
"(",
"'grant_type'",
",",
"'authorization_code'",
")",
",",
"(",
"'client_id'",
",",
"client_id",
")",
",",
"(",
"... | Exchange a provided OAuth code for an OAuth access token, 'expires in'
value and refresh token. | [
"Exchange",
"a",
"provided",
"OAuth",
"code",
"for",
"an",
"OAuth",
"access",
"token",
"expires",
"in",
"value",
"and",
"refresh",
"token",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/createsend.py#L82-L101 |
43,573 | campaignmonitor/createsend-python | lib/createsend/createsend.py | CreateSendBase.refresh_token | def refresh_token(self):
"""Refresh an OAuth token given a refresh token."""
if (not self.auth_details or
not 'refresh_token' in self.auth_details or
not self.auth_details['refresh_token']):
raise Exception(
"auth_details['refresh_token'] does ... | python | def refresh_token(self):
"""Refresh an OAuth token given a refresh token."""
if (not self.auth_details or
not 'refresh_token' in self.auth_details or
not self.auth_details['refresh_token']):
raise Exception(
"auth_details['refresh_token'] does ... | [
"def",
"refresh_token",
"(",
"self",
")",
":",
"if",
"(",
"not",
"self",
".",
"auth_details",
"or",
"not",
"'refresh_token'",
"in",
"self",
".",
"auth_details",
"or",
"not",
"self",
".",
"auth_details",
"[",
"'refresh_token'",
"]",
")",
":",
"raise",
"Exce... | Refresh an OAuth token given a refresh token. | [
"Refresh",
"an",
"OAuth",
"token",
"given",
"a",
"refresh",
"token",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/createsend.py#L116-L137 |
43,574 | campaignmonitor/createsend-python | lib/createsend/createsend.py | CreateSendBase.stub_request | def stub_request(self, expected_url, filename, status=None, body=None):
"""Stub a web request for testing."""
self.fake_web = True
self.faker = get_faker(expected_url, filename, status, body) | python | def stub_request(self, expected_url, filename, status=None, body=None):
"""Stub a web request for testing."""
self.fake_web = True
self.faker = get_faker(expected_url, filename, status, body) | [
"def",
"stub_request",
"(",
"self",
",",
"expected_url",
",",
"filename",
",",
"status",
"=",
"None",
",",
"body",
"=",
"None",
")",
":",
"self",
".",
"fake_web",
"=",
"True",
"self",
".",
"faker",
"=",
"get_faker",
"(",
"expected_url",
",",
"filename",
... | Stub a web request for testing. | [
"Stub",
"a",
"web",
"request",
"for",
"testing",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/createsend.py#L139-L142 |
43,575 | campaignmonitor/createsend-python | lib/createsend/person.py | Person.get | def get(self, client_id=None, email_address=None):
"""Gets a person by client ID and email address."""
params = {"email": email_address or self.email_address}
response = self._get("/clients/%s/people.json" %
(client_id or self.client_id), params=params)
retur... | python | def get(self, client_id=None, email_address=None):
"""Gets a person by client ID and email address."""
params = {"email": email_address or self.email_address}
response = self._get("/clients/%s/people.json" %
(client_id or self.client_id), params=params)
retur... | [
"def",
"get",
"(",
"self",
",",
"client_id",
"=",
"None",
",",
"email_address",
"=",
"None",
")",
":",
"params",
"=",
"{",
"\"email\"",
":",
"email_address",
"or",
"self",
".",
"email_address",
"}",
"response",
"=",
"self",
".",
"_get",
"(",
"\"/clients/... | Gets a person by client ID and email address. | [
"Gets",
"a",
"person",
"by",
"client",
"ID",
"and",
"email",
"address",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/person.py#L17-L22 |
43,576 | campaignmonitor/createsend-python | lib/createsend/person.py | Person.add | def add(self, client_id, email_address, name, access_level, password):
"""Adds a person to a client. Password is optional and if not supplied, an invitation will be emailed to the person"""
body = {
"EmailAddress": email_address,
"Name": name,
"AccessLevel": access_le... | python | def add(self, client_id, email_address, name, access_level, password):
"""Adds a person to a client. Password is optional and if not supplied, an invitation will be emailed to the person"""
body = {
"EmailAddress": email_address,
"Name": name,
"AccessLevel": access_le... | [
"def",
"add",
"(",
"self",
",",
"client_id",
",",
"email_address",
",",
"name",
",",
"access_level",
",",
"password",
")",
":",
"body",
"=",
"{",
"\"EmailAddress\"",
":",
"email_address",
",",
"\"Name\"",
":",
"name",
",",
"\"AccessLevel\"",
":",
"access_lev... | Adds a person to a client. Password is optional and if not supplied, an invitation will be emailed to the person | [
"Adds",
"a",
"person",
"to",
"a",
"client",
".",
"Password",
"is",
"optional",
"and",
"if",
"not",
"supplied",
"an",
"invitation",
"will",
"be",
"emailed",
"to",
"the",
"person"
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/person.py#L24-L33 |
43,577 | campaignmonitor/createsend-python | lib/createsend/person.py | Person.update | def update(self, new_email_address, name, access_level, password=None):
"""Updates the details for a person. Password is optional and is only updated if supplied."""
params = {"email": self.email_address}
body = {
"EmailAddress": new_email_address,
"Name": name,
... | python | def update(self, new_email_address, name, access_level, password=None):
"""Updates the details for a person. Password is optional and is only updated if supplied."""
params = {"email": self.email_address}
body = {
"EmailAddress": new_email_address,
"Name": name,
... | [
"def",
"update",
"(",
"self",
",",
"new_email_address",
",",
"name",
",",
"access_level",
",",
"password",
"=",
"None",
")",
":",
"params",
"=",
"{",
"\"email\"",
":",
"self",
".",
"email_address",
"}",
"body",
"=",
"{",
"\"EmailAddress\"",
":",
"new_email... | Updates the details for a person. Password is optional and is only updated if supplied. | [
"Updates",
"the",
"details",
"for",
"a",
"person",
".",
"Password",
"is",
"optional",
"and",
"is",
"only",
"updated",
"if",
"supplied",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/person.py#L35-L47 |
43,578 | campaignmonitor/createsend-python | lib/createsend/campaign.py | Campaign.create | def create(self, client_id, subject, name, from_name, from_email, reply_to, html_url,
text_url, list_ids, segment_ids):
"""Creates a new campaign for a client.
:param client_id: String representing the ID of the client for whom the
campaign will be created.
:param subje... | python | def create(self, client_id, subject, name, from_name, from_email, reply_to, html_url,
text_url, list_ids, segment_ids):
"""Creates a new campaign for a client.
:param client_id: String representing the ID of the client for whom the
campaign will be created.
:param subje... | [
"def",
"create",
"(",
"self",
",",
"client_id",
",",
"subject",
",",
"name",
",",
"from_name",
",",
"from_email",
",",
"reply_to",
",",
"html_url",
",",
"text_url",
",",
"list_ids",
",",
"segment_ids",
")",
":",
"body",
"=",
"{",
"\"Subject\"",
":",
"sub... | Creates a new campaign for a client.
:param client_id: String representing the ID of the client for whom the
campaign will be created.
:param subject: String representing the subject of the campaign.
:param name: String representing the name of the campaign.
:param from_name: ... | [
"Creates",
"a",
"new",
"campaign",
"for",
"a",
"client",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/campaign.py#L16-L50 |
43,579 | campaignmonitor/createsend-python | lib/createsend/campaign.py | Campaign.create_from_template | def create_from_template(self, client_id, subject, name, from_name,
from_email, reply_to, list_ids, segment_ids, template_id, template_content):
"""Creates a new campaign for a client, from a template.
:param client_id: String representing the ID of the client for whom the
... | python | def create_from_template(self, client_id, subject, name, from_name,
from_email, reply_to, list_ids, segment_ids, template_id, template_content):
"""Creates a new campaign for a client, from a template.
:param client_id: String representing the ID of the client for whom the
... | [
"def",
"create_from_template",
"(",
"self",
",",
"client_id",
",",
"subject",
",",
"name",
",",
"from_name",
",",
"from_email",
",",
"reply_to",
",",
"list_ids",
",",
"segment_ids",
",",
"template_id",
",",
"template_content",
")",
":",
"body",
"=",
"{",
"\"... | Creates a new campaign for a client, from a template.
:param client_id: String representing the ID of the client for whom the
campaign will be created.
:param subject: String representing the subject of the campaign.
:param name: String representing the name of the campaign.
:... | [
"Creates",
"a",
"new",
"campaign",
"for",
"a",
"client",
"from",
"a",
"template",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/campaign.py#L52-L88 |
43,580 | campaignmonitor/createsend-python | lib/createsend/campaign.py | Campaign.send_preview | def send_preview(self, recipients, personalize="fallback"):
"""Sends a preview of this campaign."""
body = {
"PreviewRecipients": [recipients] if isinstance(recipients, str) else recipients,
"Personalize": personalize}
response = self._post(self.uri_for("sendpreview"), js... | python | def send_preview(self, recipients, personalize="fallback"):
"""Sends a preview of this campaign."""
body = {
"PreviewRecipients": [recipients] if isinstance(recipients, str) else recipients,
"Personalize": personalize}
response = self._post(self.uri_for("sendpreview"), js... | [
"def",
"send_preview",
"(",
"self",
",",
"recipients",
",",
"personalize",
"=",
"\"fallback\"",
")",
":",
"body",
"=",
"{",
"\"PreviewRecipients\"",
":",
"[",
"recipients",
"]",
"if",
"isinstance",
"(",
"recipients",
",",
"str",
")",
"else",
"recipients",
",... | Sends a preview of this campaign. | [
"Sends",
"a",
"preview",
"of",
"this",
"campaign",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/campaign.py#L90-L95 |
43,581 | campaignmonitor/createsend-python | lib/createsend/campaign.py | Campaign.send | def send(self, confirmation_email, send_date="immediately"):
"""Sends this campaign."""
body = {
"ConfirmationEmail": confirmation_email,
"SendDate": send_date}
response = self._post(self.uri_for("send"), json.dumps(body)) | python | def send(self, confirmation_email, send_date="immediately"):
"""Sends this campaign."""
body = {
"ConfirmationEmail": confirmation_email,
"SendDate": send_date}
response = self._post(self.uri_for("send"), json.dumps(body)) | [
"def",
"send",
"(",
"self",
",",
"confirmation_email",
",",
"send_date",
"=",
"\"immediately\"",
")",
":",
"body",
"=",
"{",
"\"ConfirmationEmail\"",
":",
"confirmation_email",
",",
"\"SendDate\"",
":",
"send_date",
"}",
"response",
"=",
"self",
".",
"_post",
... | Sends this campaign. | [
"Sends",
"this",
"campaign",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/campaign.py#L97-L102 |
43,582 | campaignmonitor/createsend-python | lib/createsend/campaign.py | Campaign.opens | def opens(self, date="", page=1, page_size=1000, order_field="date", order_direction="asc"):
"""Retrieves the opens for this campaign."""
params = {
"date": date,
"page": page,
"pagesize": page_size,
"orderfield": order_field,
"orderdirection":... | python | def opens(self, date="", page=1, page_size=1000, order_field="date", order_direction="asc"):
"""Retrieves the opens for this campaign."""
params = {
"date": date,
"page": page,
"pagesize": page_size,
"orderfield": order_field,
"orderdirection":... | [
"def",
"opens",
"(",
"self",
",",
"date",
"=",
"\"\"",
",",
"page",
"=",
"1",
",",
"page_size",
"=",
"1000",
",",
"order_field",
"=",
"\"date\"",
",",
"order_direction",
"=",
"\"asc\"",
")",
":",
"params",
"=",
"{",
"\"date\"",
":",
"date",
",",
"\"p... | Retrieves the opens for this campaign. | [
"Retrieves",
"the",
"opens",
"for",
"this",
"campaign",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/campaign.py#L137-L146 |
43,583 | campaignmonitor/createsend-python | lib/createsend/client.py | Client.create | def create(self, company, timezone, country):
"""Creates a client."""
body = {
"CompanyName": company,
"TimeZone": timezone,
"Country": country}
response = self._post("/clients.json", json.dumps(body))
self.client_id = json_to_py(response)
ret... | python | def create(self, company, timezone, country):
"""Creates a client."""
body = {
"CompanyName": company,
"TimeZone": timezone,
"Country": country}
response = self._post("/clients.json", json.dumps(body))
self.client_id = json_to_py(response)
ret... | [
"def",
"create",
"(",
"self",
",",
"company",
",",
"timezone",
",",
"country",
")",
":",
"body",
"=",
"{",
"\"CompanyName\"",
":",
"company",
",",
"\"TimeZone\"",
":",
"timezone",
",",
"\"Country\"",
":",
"country",
"}",
"response",
"=",
"self",
".",
"_p... | Creates a client. | [
"Creates",
"a",
"client",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/client.py#L16-L25 |
43,584 | campaignmonitor/createsend-python | lib/createsend/client.py | Client.lists_for_email | def lists_for_email(self, email_address):
"""Gets the lists across a client to which a subscriber with a particular
email address belongs."""
params = {"email": email_address}
response = self._get(self.uri_for("listsforemail"), params=params)
return json_to_py(response) | python | def lists_for_email(self, email_address):
"""Gets the lists across a client to which a subscriber with a particular
email address belongs."""
params = {"email": email_address}
response = self._get(self.uri_for("listsforemail"), params=params)
return json_to_py(response) | [
"def",
"lists_for_email",
"(",
"self",
",",
"email_address",
")",
":",
"params",
"=",
"{",
"\"email\"",
":",
"email_address",
"}",
"response",
"=",
"self",
".",
"_get",
"(",
"self",
".",
"uri_for",
"(",
"\"listsforemail\"",
")",
",",
"params",
"=",
"params... | Gets the lists across a client to which a subscriber with a particular
email address belongs. | [
"Gets",
"the",
"lists",
"across",
"a",
"client",
"to",
"which",
"a",
"subscriber",
"with",
"a",
"particular",
"email",
"address",
"belongs",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/client.py#L52-L57 |
43,585 | campaignmonitor/createsend-python | lib/createsend/client.py | Client.suppressionlist | def suppressionlist(self, page=1, page_size=1000, order_field="email", order_direction="asc"):
"""Gets this client's suppression list."""
params = {
"page": page,
"pagesize": page_size,
"orderfield": order_field,
"orderdirection": order_direction}
... | python | def suppressionlist(self, page=1, page_size=1000, order_field="email", order_direction="asc"):
"""Gets this client's suppression list."""
params = {
"page": page,
"pagesize": page_size,
"orderfield": order_field,
"orderdirection": order_direction}
... | [
"def",
"suppressionlist",
"(",
"self",
",",
"page",
"=",
"1",
",",
"page_size",
"=",
"1000",
",",
"order_field",
"=",
"\"email\"",
",",
"order_direction",
"=",
"\"asc\"",
")",
":",
"params",
"=",
"{",
"\"page\"",
":",
"page",
",",
"\"pagesize\"",
":",
"p... | Gets this client's suppression list. | [
"Gets",
"this",
"client",
"s",
"suppression",
"list",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/client.py#L64-L72 |
43,586 | campaignmonitor/createsend-python | lib/createsend/client.py | Client.suppress | def suppress(self, email):
"""Adds email addresses to a client's suppression list"""
body = {
"EmailAddresses": [email] if isinstance(email, str) else email}
response = self._post(self.uri_for("suppress"), json.dumps(body)) | python | def suppress(self, email):
"""Adds email addresses to a client's suppression list"""
body = {
"EmailAddresses": [email] if isinstance(email, str) else email}
response = self._post(self.uri_for("suppress"), json.dumps(body)) | [
"def",
"suppress",
"(",
"self",
",",
"email",
")",
":",
"body",
"=",
"{",
"\"EmailAddresses\"",
":",
"[",
"email",
"]",
"if",
"isinstance",
"(",
"email",
",",
"str",
")",
"else",
"email",
"}",
"response",
"=",
"self",
".",
"_post",
"(",
"self",
".",
... | Adds email addresses to a client's suppression list | [
"Adds",
"email",
"addresses",
"to",
"a",
"client",
"s",
"suppression",
"list"
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/client.py#L74-L78 |
43,587 | campaignmonitor/createsend-python | lib/createsend/client.py | Client.unsuppress | def unsuppress(self, email):
"""Unsuppresses an email address by removing it from the the client's
suppression list"""
params = {"email": email}
response = self._put(self.uri_for("unsuppress"),
body=" ", params=params) | python | def unsuppress(self, email):
"""Unsuppresses an email address by removing it from the the client's
suppression list"""
params = {"email": email}
response = self._put(self.uri_for("unsuppress"),
body=" ", params=params) | [
"def",
"unsuppress",
"(",
"self",
",",
"email",
")",
":",
"params",
"=",
"{",
"\"email\"",
":",
"email",
"}",
"response",
"=",
"self",
".",
"_put",
"(",
"self",
".",
"uri_for",
"(",
"\"unsuppress\"",
")",
",",
"body",
"=",
"\" \"",
",",
"params",
"="... | Unsuppresses an email address by removing it from the the client's
suppression list | [
"Unsuppresses",
"an",
"email",
"address",
"by",
"removing",
"it",
"from",
"the",
"the",
"client",
"s",
"suppression",
"list"
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/client.py#L80-L85 |
43,588 | campaignmonitor/createsend-python | lib/createsend/client.py | Client.set_payg_billing | def set_payg_billing(self, currency, can_purchase_credits, client_pays, markup_percentage,
markup_on_delivery=0, markup_per_recipient=0, markup_on_design_spam_test=0):
"""Sets the PAYG billing settings for this client."""
body = {
"Currency": currency,
"C... | python | def set_payg_billing(self, currency, can_purchase_credits, client_pays, markup_percentage,
markup_on_delivery=0, markup_per_recipient=0, markup_on_design_spam_test=0):
"""Sets the PAYG billing settings for this client."""
body = {
"Currency": currency,
"C... | [
"def",
"set_payg_billing",
"(",
"self",
",",
"currency",
",",
"can_purchase_credits",
",",
"client_pays",
",",
"markup_percentage",
",",
"markup_on_delivery",
"=",
"0",
",",
"markup_per_recipient",
"=",
"0",
",",
"markup_on_design_spam_test",
"=",
"0",
")",
":",
"... | Sets the PAYG billing settings for this client. | [
"Sets",
"the",
"PAYG",
"billing",
"settings",
"for",
"this",
"client",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/client.py#L99-L110 |
43,589 | campaignmonitor/createsend-python | lib/createsend/client.py | Client.set_monthly_billing | def set_monthly_billing(self, currency, client_pays, markup_percentage, monthly_scheme=None):
"""Sets the monthly billing settings for this client."""
body = {
"Currency": currency,
"ClientPays": client_pays,
"MarkupPercentage": markup_percentage}
if monthly_... | python | def set_monthly_billing(self, currency, client_pays, markup_percentage, monthly_scheme=None):
"""Sets the monthly billing settings for this client."""
body = {
"Currency": currency,
"ClientPays": client_pays,
"MarkupPercentage": markup_percentage}
if monthly_... | [
"def",
"set_monthly_billing",
"(",
"self",
",",
"currency",
",",
"client_pays",
",",
"markup_percentage",
",",
"monthly_scheme",
"=",
"None",
")",
":",
"body",
"=",
"{",
"\"Currency\"",
":",
"currency",
",",
"\"ClientPays\"",
":",
"client_pays",
",",
"\"MarkupPe... | Sets the monthly billing settings for this client. | [
"Sets",
"the",
"monthly",
"billing",
"settings",
"for",
"this",
"client",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/client.py#L112-L123 |
43,590 | campaignmonitor/createsend-python | lib/createsend/client.py | Client.transfer_credits | def transfer_credits(self, credits, can_use_my_credits_when_they_run_out):
"""Transfer credits to or from this client.
:param credits: An Integer representing the number of credits to transfer.
This value may be either positive if you want to allocate credits from
your account to th... | python | def transfer_credits(self, credits, can_use_my_credits_when_they_run_out):
"""Transfer credits to or from this client.
:param credits: An Integer representing the number of credits to transfer.
This value may be either positive if you want to allocate credits from
your account to th... | [
"def",
"transfer_credits",
"(",
"self",
",",
"credits",
",",
"can_use_my_credits_when_they_run_out",
")",
":",
"body",
"=",
"{",
"\"Credits\"",
":",
"credits",
",",
"\"CanUseMyCreditsWhenTheyRunOut\"",
":",
"can_use_my_credits_when_they_run_out",
"}",
"response",
"=",
"... | Transfer credits to or from this client.
:param credits: An Integer representing the number of credits to transfer.
This value may be either positive if you want to allocate credits from
your account to the client, or negative if you want to deduct credits
from the client back int... | [
"Transfer",
"credits",
"to",
"or",
"from",
"this",
"client",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/client.py#L125-L148 |
43,591 | campaignmonitor/createsend-python | lib/createsend/client.py | Client.set_primary_contact | def set_primary_contact(self, email):
"""assigns the primary contact for this client"""
params = {"email": email}
response = self._put(self.uri_for('primarycontact'), params=params)
return json_to_py(response) | python | def set_primary_contact(self, email):
"""assigns the primary contact for this client"""
params = {"email": email}
response = self._put(self.uri_for('primarycontact'), params=params)
return json_to_py(response) | [
"def",
"set_primary_contact",
"(",
"self",
",",
"email",
")",
":",
"params",
"=",
"{",
"\"email\"",
":",
"email",
"}",
"response",
"=",
"self",
".",
"_put",
"(",
"self",
".",
"uri_for",
"(",
"'primarycontact'",
")",
",",
"params",
"=",
"params",
")",
"... | assigns the primary contact for this client | [
"assigns",
"the",
"primary",
"contact",
"for",
"this",
"client"
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/client.py#L160-L164 |
43,592 | campaignmonitor/createsend-python | lib/createsend/transactional.py | Transactional.smart_email_list | def smart_email_list(self, status="all", client_id=None):
"""Gets the smart email list."""
if client_id is None:
response = self._get(
"/transactional/smartEmail?status=%s" % status)
else:
response = self._get(
"/transactional/smartEmail?st... | python | def smart_email_list(self, status="all", client_id=None):
"""Gets the smart email list."""
if client_id is None:
response = self._get(
"/transactional/smartEmail?status=%s" % status)
else:
response = self._get(
"/transactional/smartEmail?st... | [
"def",
"smart_email_list",
"(",
"self",
",",
"status",
"=",
"\"all\"",
",",
"client_id",
"=",
"None",
")",
":",
"if",
"client_id",
"is",
"None",
":",
"response",
"=",
"self",
".",
"_get",
"(",
"\"/transactional/smartEmail?status=%s\"",
"%",
"status",
")",
"e... | Gets the smart email list. | [
"Gets",
"the",
"smart",
"email",
"list",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/transactional.py#L16-L24 |
43,593 | campaignmonitor/createsend-python | lib/createsend/transactional.py | Transactional.smart_email_send | def smart_email_send(self, smart_email_id, to, consent_to_track, cc=None, bcc=None, attachments=None, data=None, add_recipients_to_list=None):
"""Sends the smart email."""
validate_consent_to_track(consent_to_track)
body = {
"To": to,
"CC": cc,
"BCC": bcc,
... | python | def smart_email_send(self, smart_email_id, to, consent_to_track, cc=None, bcc=None, attachments=None, data=None, add_recipients_to_list=None):
"""Sends the smart email."""
validate_consent_to_track(consent_to_track)
body = {
"To": to,
"CC": cc,
"BCC": bcc,
... | [
"def",
"smart_email_send",
"(",
"self",
",",
"smart_email_id",
",",
"to",
",",
"consent_to_track",
",",
"cc",
"=",
"None",
",",
"bcc",
"=",
"None",
",",
"attachments",
"=",
"None",
",",
"data",
"=",
"None",
",",
"add_recipients_to_list",
"=",
"None",
")",
... | Sends the smart email. | [
"Sends",
"the",
"smart",
"email",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/transactional.py#L31-L45 |
43,594 | campaignmonitor/createsend-python | lib/createsend/transactional.py | Transactional.classic_email_send | def classic_email_send(self, subject, from_address, to, consent_to_track, client_id=None, cc=None, bcc=None, html=None, text=None, attachments=None, track_opens=True, track_clicks=True, inline_css=True, group=None, add_recipients_to_list=None):
"""Sends a classic email."""
validate_consent_to_track(cons... | python | def classic_email_send(self, subject, from_address, to, consent_to_track, client_id=None, cc=None, bcc=None, html=None, text=None, attachments=None, track_opens=True, track_clicks=True, inline_css=True, group=None, add_recipients_to_list=None):
"""Sends a classic email."""
validate_consent_to_track(cons... | [
"def",
"classic_email_send",
"(",
"self",
",",
"subject",
",",
"from_address",
",",
"to",
",",
"consent_to_track",
",",
"client_id",
"=",
"None",
",",
"cc",
"=",
"None",
",",
"bcc",
"=",
"None",
",",
"html",
"=",
"None",
",",
"text",
"=",
"None",
",",
... | Sends a classic email. | [
"Sends",
"a",
"classic",
"email",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/transactional.py#L47-L72 |
43,595 | campaignmonitor/createsend-python | lib/createsend/transactional.py | Transactional.classic_email_groups | def classic_email_groups(self, client_id=None):
"""Gets the list of classic email groups."""
if client_id is None:
response = self._get("/transactional/classicEmail/groups")
else:
response = self._get(
"/transactional/classicEmail/groups?clientID=%s" % cli... | python | def classic_email_groups(self, client_id=None):
"""Gets the list of classic email groups."""
if client_id is None:
response = self._get("/transactional/classicEmail/groups")
else:
response = self._get(
"/transactional/classicEmail/groups?clientID=%s" % cli... | [
"def",
"classic_email_groups",
"(",
"self",
",",
"client_id",
"=",
"None",
")",
":",
"if",
"client_id",
"is",
"None",
":",
"response",
"=",
"self",
".",
"_get",
"(",
"\"/transactional/classicEmail/groups\"",
")",
"else",
":",
"response",
"=",
"self",
".",
"_... | Gets the list of classic email groups. | [
"Gets",
"the",
"list",
"of",
"classic",
"email",
"groups",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/transactional.py#L74-L81 |
43,596 | campaignmonitor/createsend-python | lib/createsend/transactional.py | Transactional.message_details | def message_details(self, message_id, statistics=False):
"""Gets the details of this message."""
response = self._get(
"/transactional/messages/%s?statistics=%s" % (message_id, statistics))
return json_to_py(response) | python | def message_details(self, message_id, statistics=False):
"""Gets the details of this message."""
response = self._get(
"/transactional/messages/%s?statistics=%s" % (message_id, statistics))
return json_to_py(response) | [
"def",
"message_details",
"(",
"self",
",",
"message_id",
",",
"statistics",
"=",
"False",
")",
":",
"response",
"=",
"self",
".",
"_get",
"(",
"\"/transactional/messages/%s?statistics=%s\"",
"%",
"(",
"message_id",
",",
"statistics",
")",
")",
"return",
"json_t... | Gets the details of this message. | [
"Gets",
"the",
"details",
"of",
"this",
"message",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/transactional.py#L93-L97 |
43,597 | campaignmonitor/createsend-python | lib/createsend/segment.py | Segment.create | def create(self, list_id, title, rulegroups):
"""Creates a new segment."""
body = {
"Title": title,
"RuleGroups": rulegroups}
response = self._post("/segments/%s.json" % list_id, json.dumps(body))
self.segment_id = json_to_py(response)
return self.segment_... | python | def create(self, list_id, title, rulegroups):
"""Creates a new segment."""
body = {
"Title": title,
"RuleGroups": rulegroups}
response = self._post("/segments/%s.json" % list_id, json.dumps(body))
self.segment_id = json_to_py(response)
return self.segment_... | [
"def",
"create",
"(",
"self",
",",
"list_id",
",",
"title",
",",
"rulegroups",
")",
":",
"body",
"=",
"{",
"\"Title\"",
":",
"title",
",",
"\"RuleGroups\"",
":",
"rulegroups",
"}",
"response",
"=",
"self",
".",
"_post",
"(",
"\"/segments/%s.json\"",
"%",
... | Creates a new segment. | [
"Creates",
"a",
"new",
"segment",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/segment.py#L16-L23 |
43,598 | campaignmonitor/createsend-python | lib/createsend/segment.py | Segment.update | def update(self, title, rulegroups):
"""Updates this segment."""
body = {
"Title": title,
"RuleGroups": rulegroups}
response = self._put("/segments/%s.json" %
self.segment_id, json.dumps(body)) | python | def update(self, title, rulegroups):
"""Updates this segment."""
body = {
"Title": title,
"RuleGroups": rulegroups}
response = self._put("/segments/%s.json" %
self.segment_id, json.dumps(body)) | [
"def",
"update",
"(",
"self",
",",
"title",
",",
"rulegroups",
")",
":",
"body",
"=",
"{",
"\"Title\"",
":",
"title",
",",
"\"RuleGroups\"",
":",
"rulegroups",
"}",
"response",
"=",
"self",
".",
"_put",
"(",
"\"/segments/%s.json\"",
"%",
"self",
".",
"se... | Updates this segment. | [
"Updates",
"this",
"segment",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/segment.py#L25-L31 |
43,599 | campaignmonitor/createsend-python | lib/createsend/segment.py | Segment.add_rulegroup | def add_rulegroup(self, rulegroup):
"""Adds a rulegroup to this segment."""
body = rulegroup
response = self._post("/segments/%s/rules.json" %
self.segment_id, json.dumps(body)) | python | def add_rulegroup(self, rulegroup):
"""Adds a rulegroup to this segment."""
body = rulegroup
response = self._post("/segments/%s/rules.json" %
self.segment_id, json.dumps(body)) | [
"def",
"add_rulegroup",
"(",
"self",
",",
"rulegroup",
")",
":",
"body",
"=",
"rulegroup",
"response",
"=",
"self",
".",
"_post",
"(",
"\"/segments/%s/rules.json\"",
"%",
"self",
".",
"segment_id",
",",
"json",
".",
"dumps",
"(",
"body",
")",
")"
] | Adds a rulegroup to this segment. | [
"Adds",
"a",
"rulegroup",
"to",
"this",
"segment",
"."
] | 4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426 | https://github.com/campaignmonitor/createsend-python/blob/4bfe2fd5cb2fc9d8f12280b23569eea0a6c66426/lib/createsend/segment.py#L33-L37 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.