partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | copy_directory | Copy an entire directory recursively | expfactory/utils.py | def copy_directory(src, dest, force=False):
''' Copy an entire directory recursively
'''
if os.path.exists(dest) and force is True:
shutil.rmtree(dest)
try:
shutil.copytree(src, dest)
except OSError as e:
# If the error was caused because the source wasn't a directory
... | def copy_directory(src, dest, force=False):
''' Copy an entire directory recursively
'''
if os.path.exists(dest) and force is True:
shutil.rmtree(dest)
try:
shutil.copytree(src, dest)
except OSError as e:
# If the error was caused because the source wasn't a directory
... | [
"Copy",
"an",
"entire",
"directory",
"recursively"
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/utils.py#L94-L108 | [
"def",
"copy_directory",
"(",
"src",
",",
"dest",
",",
"force",
"=",
"False",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"dest",
")",
"and",
"force",
"is",
"True",
":",
"shutil",
".",
"rmtree",
"(",
"dest",
")",
"try",
":",
"shutil",
... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | clone | clone a repository from Github | expfactory/utils.py | def clone(url, tmpdir=None):
'''clone a repository from Github'''
if tmpdir is None:
tmpdir = tempfile.mkdtemp()
name = os.path.basename(url).replace('.git', '')
dest = '%s/%s' %(tmpdir,name)
return_code = os.system('git clone %s %s' %(url,dest))
if return_code == 0:
return dest
... | def clone(url, tmpdir=None):
'''clone a repository from Github'''
if tmpdir is None:
tmpdir = tempfile.mkdtemp()
name = os.path.basename(url).replace('.git', '')
dest = '%s/%s' %(tmpdir,name)
return_code = os.system('git clone %s %s' %(url,dest))
if return_code == 0:
return dest
... | [
"clone",
"a",
"repository",
"from",
"Github"
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/utils.py#L125-L135 | [
"def",
"clone",
"(",
"url",
",",
"tmpdir",
"=",
"None",
")",
":",
"if",
"tmpdir",
"is",
"None",
":",
"tmpdir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
")",
"name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"url",
")",
".",
"replace",
"(",
"'.gi... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | run_command | run_command uses subprocess to send a command to the terminal.
:param cmd: the command to send, should be a list for subprocess | expfactory/utils.py | def run_command(cmd):
'''run_command uses subprocess to send a command to the terminal.
:param cmd: the command to send, should be a list for subprocess
'''
output = Popen(cmd,stderr=STDOUT,stdout=PIPE)
t = output.communicate()[0],output.returncode
output = {'message':t[0],
'return... | def run_command(cmd):
'''run_command uses subprocess to send a command to the terminal.
:param cmd: the command to send, should be a list for subprocess
'''
output = Popen(cmd,stderr=STDOUT,stdout=PIPE)
t = output.communicate()[0],output.returncode
output = {'message':t[0],
'return... | [
"run_command",
"uses",
"subprocess",
"to",
"send",
"a",
"command",
"to",
"the",
"terminal",
".",
":",
"param",
"cmd",
":",
"the",
"command",
"to",
"send",
"should",
"be",
"a",
"list",
"for",
"subprocess"
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/utils.py#L138-L147 | [
"def",
"run_command",
"(",
"cmd",
")",
":",
"output",
"=",
"Popen",
"(",
"cmd",
",",
"stderr",
"=",
"STDOUT",
",",
"stdout",
"=",
"PIPE",
")",
"t",
"=",
"output",
".",
"communicate",
"(",
")",
"[",
"0",
"]",
",",
"output",
".",
"returncode",
"outpu... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | get_template | read in and return a template file | expfactory/utils.py | def get_template(name, base=None):
'''read in and return a template file
'''
# If the file doesn't exist, assume relative to base
template_file = name
if not os.path.exists(template_file):
if base is None:
base = get_templatedir()
template_file = "%s/%s" %(base, name)
... | def get_template(name, base=None):
'''read in and return a template file
'''
# If the file doesn't exist, assume relative to base
template_file = name
if not os.path.exists(template_file):
if base is None:
base = get_templatedir()
template_file = "%s/%s" %(base, name)
... | [
"read",
"in",
"and",
"return",
"a",
"template",
"file"
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/utils.py#L155-L170 | [
"def",
"get_template",
"(",
"name",
",",
"base",
"=",
"None",
")",
":",
"# If the file doesn't exist, assume relative to base",
"template_file",
"=",
"name",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"template_file",
")",
":",
"if",
"base",
"is",
"No... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | sub_template | make a substitution for a template_tag in a template | expfactory/utils.py | def sub_template(template,template_tag,substitution):
'''make a substitution for a template_tag in a template
'''
template = template.replace(template_tag,substitution)
return template | def sub_template(template,template_tag,substitution):
'''make a substitution for a template_tag in a template
'''
template = template.replace(template_tag,substitution)
return template | [
"make",
"a",
"substitution",
"for",
"a",
"template_tag",
"in",
"a",
"template"
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/utils.py#L173-L177 | [
"def",
"sub_template",
"(",
"template",
",",
"template_tag",
",",
"substitution",
")",
":",
"template",
"=",
"template",
".",
"replace",
"(",
"template_tag",
",",
"substitution",
")",
"return",
"template"
] | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | get_post_fields | parse through a request, and return fields from post in a dictionary | expfactory/utils.py | def get_post_fields(request):
'''parse through a request, and return fields from post in a dictionary
'''
fields = dict()
for field,value in request.form.items():
fields[field] = value
return fields | def get_post_fields(request):
'''parse through a request, and return fields from post in a dictionary
'''
fields = dict()
for field,value in request.form.items():
fields[field] = value
return fields | [
"parse",
"through",
"a",
"request",
"and",
"return",
"fields",
"from",
"post",
"in",
"a",
"dictionary"
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/utils.py#L214-L220 | [
"def",
"get_post_fields",
"(",
"request",
")",
":",
"fields",
"=",
"dict",
"(",
")",
"for",
"field",
",",
"value",
"in",
"request",
".",
"form",
".",
"items",
"(",
")",
":",
"fields",
"[",
"field",
"]",
"=",
"value",
"return",
"fields"
] | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | getenv | getenv will attempt to get an environment variable. If the variable
is not found, None is returned.
:param variable_key: the variable name
:param required: exit with error if not found
:param silent: Do not print debugging information for variable | expfactory/utils.py | def getenv(variable_key, default=None, required=False, silent=True):
'''getenv will attempt to get an environment variable. If the variable
is not found, None is returned.
:param variable_key: the variable name
:param required: exit with error if not found
:param silent: Do not print debugging infor... | def getenv(variable_key, default=None, required=False, silent=True):
'''getenv will attempt to get an environment variable. If the variable
is not found, None is returned.
:param variable_key: the variable name
:param required: exit with error if not found
:param silent: Do not print debugging infor... | [
"getenv",
"will",
"attempt",
"to",
"get",
"an",
"environment",
"variable",
".",
"If",
"the",
"variable",
"is",
"not",
"found",
"None",
"is",
"returned",
".",
":",
"param",
"variable_key",
":",
"the",
"variable",
"name",
":",
"param",
"required",
":",
"exit... | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/utils.py#L236-L254 | [
"def",
"getenv",
"(",
"variable_key",
",",
"default",
"=",
"None",
",",
"required",
"=",
"False",
",",
"silent",
"=",
"True",
")",
":",
"variable",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"variable_key",
",",
"default",
")",
"if",
"variable",
"is",... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | parse | Parse the data stream using the supplied template. The data stream
WILL NOT be automatically closed.
:data: Input data, can be either a string or a file-like object (StringIO, file, etc)
:template: template contents (str)
:data_file: PATH to the data to be used as the input stream
:template_file: t... | pfp/__init__.py | def parse(
data = None,
template = None,
data_file = None,
template_file = None,
interp = None,
debug = False,
predefines = True,
int3 = True,
keep_successful = False,
printf ... | def parse(
data = None,
template = None,
data_file = None,
template_file = None,
interp = None,
debug = False,
predefines = True,
int3 = True,
keep_successful = False,
printf ... | [
"Parse",
"the",
"data",
"stream",
"using",
"the",
"supplied",
"template",
".",
"The",
"data",
"stream",
"WILL",
"NOT",
"be",
"automatically",
"closed",
"."
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/__init__.py#L19-L98 | [
"def",
"parse",
"(",
"data",
"=",
"None",
",",
"template",
"=",
"None",
",",
"data_file",
"=",
"None",
",",
"template_file",
"=",
"None",
",",
"interp",
"=",
"None",
",",
"debug",
"=",
"False",
",",
"predefines",
"=",
"True",
",",
"int3",
"=",
"True"... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Checksum | Runs a simple checksum on a file and returns the result as a int64. The
algorithm can be one of the following constants:
CHECKSUM_BYTE - Treats the file as a set of unsigned bytes
CHECKSUM_SHORT_LE - Treats the file as a set of unsigned little-endian shorts
CHECKSUM_SHORT_BE - Treats the file as a set ... | pfp/native/compat_tools.py | def Checksum(params, ctxt, scope, stream, coord):
"""
Runs a simple checksum on a file and returns the result as a int64. The
algorithm can be one of the following constants:
CHECKSUM_BYTE - Treats the file as a set of unsigned bytes
CHECKSUM_SHORT_LE - Treats the file as a set of unsigned little-e... | def Checksum(params, ctxt, scope, stream, coord):
"""
Runs a simple checksum on a file and returns the result as a int64. The
algorithm can be one of the following constants:
CHECKSUM_BYTE - Treats the file as a set of unsigned bytes
CHECKSUM_SHORT_LE - Treats the file as a set of unsigned little-e... | [
"Runs",
"a",
"simple",
"checksum",
"on",
"a",
"file",
"and",
"returns",
"the",
"result",
"as",
"a",
"int64",
".",
"The",
"algorithm",
"can",
"be",
"one",
"of",
"the",
"following",
"constants",
":"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/native/compat_tools.py#L47-L133 | [
"def",
"Checksum",
"(",
"params",
",",
"ctxt",
",",
"scope",
",",
"stream",
",",
"coord",
")",
":",
"checksum_types",
"=",
"{",
"0",
":",
"\"CHECKSUM_BYTE\"",
",",
"# Treats the file as a set of unsigned bytes",
"1",
":",
"\"CHECKSUM_SHORT_LE\"",
",",
"# Treats th... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | FindAll | This function converts the argument data into a set of hex bytes
and then searches the current file for all occurrences of those
bytes. data may be any of the basic types or an array of one of
the types. If data is an array of signed bytes, it is assumed to
be a null-terminated string. To search for an ... | pfp/native/compat_tools.py | def FindAll(params, ctxt, scope, stream, coord, interp):
"""
This function converts the argument data into a set of hex bytes
and then searches the current file for all occurrences of those
bytes. data may be any of the basic types or an array of one of
the types. If data is an array of signed bytes... | def FindAll(params, ctxt, scope, stream, coord, interp):
"""
This function converts the argument data into a set of hex bytes
and then searches the current file for all occurrences of those
bytes. data may be any of the basic types or an array of one of
the types. If data is an array of signed bytes... | [
"This",
"function",
"converts",
"the",
"argument",
"data",
"into",
"a",
"set",
"of",
"hex",
"bytes",
"and",
"then",
"searches",
"the",
"current",
"file",
"for",
"all",
"occurrences",
"of",
"those",
"bytes",
".",
"data",
"may",
"be",
"any",
"of",
"the",
"... | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/native/compat_tools.py#L537-L575 | [
"def",
"FindAll",
"(",
"params",
",",
"ctxt",
",",
"scope",
",",
"stream",
",",
"coord",
",",
"interp",
")",
":",
"matches_iter",
"=",
"_find_helper",
"(",
"params",
",",
"ctxt",
",",
"scope",
",",
"stream",
",",
"coord",
",",
"interp",
")",
"matches",... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | FindFirst | This function is identical to the FindAll function except that the
return value is the position of the first occurrence of the target
found. A negative number is returned if the value could not be found. | pfp/native/compat_tools.py | def FindFirst(params, ctxt, scope, stream, coord, interp):
"""
This function is identical to the FindAll function except that the
return value is the position of the first occurrence of the target
found. A negative number is returned if the value could not be found.
"""
global FIND_MATCHES_ITER
... | def FindFirst(params, ctxt, scope, stream, coord, interp):
"""
This function is identical to the FindAll function except that the
return value is the position of the first occurrence of the target
found. A negative number is returned if the value could not be found.
"""
global FIND_MATCHES_ITER
... | [
"This",
"function",
"is",
"identical",
"to",
"the",
"FindAll",
"function",
"except",
"that",
"the",
"return",
"value",
"is",
"the",
"position",
"of",
"the",
"first",
"occurrence",
"of",
"the",
"target",
"found",
".",
"A",
"negative",
"number",
"is",
"returne... | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/native/compat_tools.py#L589-L602 | [
"def",
"FindFirst",
"(",
"params",
",",
"ctxt",
",",
"scope",
",",
"stream",
",",
"coord",
",",
"interp",
")",
":",
"global",
"FIND_MATCHES_ITER",
"FIND_MATCHES_ITER",
"=",
"_find_helper",
"(",
"params",
",",
"ctxt",
",",
"scope",
",",
"stream",
",",
"coor... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | FindNext | This function returns the position of the next occurrence of the
target value specified with the FindFirst function. If dir is 1, the
find direction is down. If dir is 0, the find direction is up. The
return value is the address of the found data, or -1 if the target
is not found. | pfp/native/compat_tools.py | def FindNext(params, ctxt, scope, stream, coord):
"""
This function returns the position of the next occurrence of the
target value specified with the FindFirst function. If dir is 1, the
find direction is down. If dir is 0, the find direction is up. The
return value is the address of the found data... | def FindNext(params, ctxt, scope, stream, coord):
"""
This function returns the position of the next occurrence of the
target value specified with the FindFirst function. If dir is 1, the
find direction is down. If dir is 0, the find direction is up. The
return value is the address of the found data... | [
"This",
"function",
"returns",
"the",
"position",
"of",
"the",
"next",
"occurrence",
"of",
"the",
"target",
"value",
"specified",
"with",
"the",
"FindFirst",
"function",
".",
"If",
"dir",
"is",
"1",
"the",
"find",
"direction",
"is",
"down",
".",
"If",
"dir... | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/native/compat_tools.py#L606-L633 | [
"def",
"FindNext",
"(",
"params",
",",
"ctxt",
",",
"scope",
",",
"stream",
",",
"coord",
")",
":",
"if",
"FIND_MATCHES_ITER",
"is",
"None",
":",
"raise",
"errors",
".",
"InvalidState",
"(",
")",
"direction",
"=",
"1",
"if",
"len",
"(",
"params",
")",
... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | generate_subid | assumes a flat (file system) database, organized by experiment id, and
subject id, with data (json) organized by subject identifier | expfactory/database/filesystem.py | def generate_subid(self, token=None):
'''assumes a flat (file system) database, organized by experiment id, and
subject id, with data (json) organized by subject identifier
'''
# Not headless auto-increments
if not token:
token = str(uuid.uuid4())
# Headless doesn't use any folder_... | def generate_subid(self, token=None):
'''assumes a flat (file system) database, organized by experiment id, and
subject id, with data (json) organized by subject identifier
'''
# Not headless auto-increments
if not token:
token = str(uuid.uuid4())
# Headless doesn't use any folder_... | [
"assumes",
"a",
"flat",
"(",
"file",
"system",
")",
"database",
"organized",
"by",
"experiment",
"id",
"and",
"subject",
"id",
"with",
"data",
"(",
"json",
")",
"organized",
"by",
"subject",
"identifier"
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/filesystem.py#L56-L66 | [
"def",
"generate_subid",
"(",
"self",
",",
"token",
"=",
"None",
")",
":",
"# Not headless auto-increments",
"if",
"not",
"token",
":",
"token",
"=",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
"# Headless doesn't use any folder_id, just generated token folder"... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | list_users | list users, each associated with a filesystem folder | expfactory/database/filesystem.py | def list_users(self):
'''list users, each associated with a filesystem folder
'''
folders = glob('%s/*' %(self.database))
folders.sort()
return [self.print_user(x) for x in folders] | def list_users(self):
'''list users, each associated with a filesystem folder
'''
folders = glob('%s/*' %(self.database))
folders.sort()
return [self.print_user(x) for x in folders] | [
"list",
"users",
"each",
"associated",
"with",
"a",
"filesystem",
"folder"
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/filesystem.py#L69-L74 | [
"def",
"list_users",
"(",
"self",
")",
":",
"folders",
"=",
"glob",
"(",
"'%s/*'",
"%",
"(",
"self",
".",
"database",
")",
")",
"folders",
".",
"sort",
"(",
")",
"return",
"[",
"self",
".",
"print_user",
"(",
"x",
")",
"for",
"x",
"in",
"folders",
... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | print_user | print a filesystem database user. A "database" folder that might end with
the participant status (e.g. _finished) is extracted to print in format
[folder] [identifier][studyid]
/scif/data/expfactory/xxxx-xxxx xxxx-xxxx[studyid] | expfactory/database/filesystem.py | def print_user(self, user):
'''print a filesystem database user. A "database" folder that might end with
the participant status (e.g. _finished) is extracted to print in format
[folder] [identifier][studyid]
/scif/data/expfactory/xxxx-xxxx xxxx-xxxx[studyid]
... | def print_user(self, user):
'''print a filesystem database user. A "database" folder that might end with
the participant status (e.g. _finished) is extracted to print in format
[folder] [identifier][studyid]
/scif/data/expfactory/xxxx-xxxx xxxx-xxxx[studyid]
... | [
"print",
"a",
"filesystem",
"database",
"user",
".",
"A",
"database",
"folder",
"that",
"might",
"end",
"with",
"the",
"participant",
"status",
"(",
"e",
".",
"g",
".",
"_finished",
")",
"is",
"extracted",
"to",
"print",
"in",
"format",
"[",
"folder",
"]... | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/filesystem.py#L77-L99 | [
"def",
"print_user",
"(",
"self",
",",
"user",
")",
":",
"status",
"=",
"\"active\"",
"if",
"user",
".",
"endswith",
"(",
"'_finished'",
")",
":",
"status",
"=",
"\"finished\"",
"elif",
"user",
".",
"endswith",
"(",
"'_revoked'",
")",
":",
"status",
"=",... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | generate_user | generate a new user on the filesystem, still session based so we
create a new identifier. This function is called from the users new
entrypoint, and it assumes we want a user generated with a token.
since we don't have a database proper, we write the folder name to
the filesystem | expfactory/database/filesystem.py | def generate_user(self, subid=None):
'''generate a new user on the filesystem, still session based so we
create a new identifier. This function is called from the users new
entrypoint, and it assumes we want a user generated with a token.
since we don't have a database proper, we write the fol... | def generate_user(self, subid=None):
'''generate a new user on the filesystem, still session based so we
create a new identifier. This function is called from the users new
entrypoint, and it assumes we want a user generated with a token.
since we don't have a database proper, we write the fol... | [
"generate",
"a",
"new",
"user",
"on",
"the",
"filesystem",
"still",
"session",
"based",
"so",
"we",
"create",
"a",
"new",
"identifier",
".",
"This",
"function",
"is",
"called",
"from",
"the",
"users",
"new",
"entrypoint",
"and",
"it",
"assumes",
"we",
"wan... | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/filesystem.py#L105-L123 | [
"def",
"generate_user",
"(",
"self",
",",
"subid",
"=",
"None",
")",
":",
"# Only generate token if subid being created",
"if",
"subid",
"is",
"None",
":",
"token",
"=",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
"subid",
"=",
"self",
".",
"generate_... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | finish_user | finish user will append "finished" (or other) to the data folder when
the user has completed (or been revoked from) the battery.
For headless, this means that the session is ended and the token
will not work again to rewrite the result. If the user needs to update
or redo an experiment, th... | expfactory/database/filesystem.py | def finish_user(self, subid, ext='finished'):
'''finish user will append "finished" (or other) to the data folder when
the user has completed (or been revoked from) the battery.
For headless, this means that the session is ended and the token
will not work again to rewrite the result. If the ... | def finish_user(self, subid, ext='finished'):
'''finish user will append "finished" (or other) to the data folder when
the user has completed (or been revoked from) the battery.
For headless, this means that the session is ended and the token
will not work again to rewrite the result. If the ... | [
"finish",
"user",
"will",
"append",
"finished",
"(",
"or",
"other",
")",
"to",
"the",
"data",
"folder",
"when",
"the",
"user",
"has",
"completed",
"(",
"or",
"been",
"revoked",
"from",
")",
"the",
"battery",
".",
"For",
"headless",
"this",
"means",
"that... | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/filesystem.py#L126-L163 | [
"def",
"finish_user",
"(",
"self",
",",
"subid",
",",
"ext",
"=",
"'finished'",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"data_base",
")",
":",
"# /scif/data",
"# Only relevant to filesystem save - the studyid is the top folder",
"if",
... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | restart_user | restart user will remove any "finished" or "revoked" extensions from
the user folder to restart the session. This command always comes from
the client users function, so we know subid does not start with the
study identifer first | expfactory/database/filesystem.py | def restart_user(self, subid):
'''restart user will remove any "finished" or "revoked" extensions from
the user folder to restart the session. This command always comes from
the client users function, so we know subid does not start with the
study identifer first
'''
if os.path.exists(s... | def restart_user(self, subid):
'''restart user will remove any "finished" or "revoked" extensions from
the user folder to restart the session. This command always comes from
the client users function, so we know subid does not start with the
study identifer first
'''
if os.path.exists(s... | [
"restart",
"user",
"will",
"remove",
"any",
"finished",
"or",
"revoked",
"extensions",
"from",
"the",
"user",
"folder",
"to",
"restart",
"the",
"session",
".",
"This",
"command",
"always",
"comes",
"from",
"the",
"client",
"users",
"function",
"so",
"we",
"k... | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/filesystem.py#L166-L183 | [
"def",
"restart_user",
"(",
"self",
",",
"subid",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"data_base",
")",
":",
"# /scif/data/<study_id>",
"data_base",
"=",
"\"%s/%s\"",
"%",
"(",
"self",
".",
"data_base",
",",
"subid",
")",
... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | validate_token | retrieve a subject based on a token. Valid means we return a participant
invalid means we return None | expfactory/database/filesystem.py | def validate_token(self, token):
'''retrieve a subject based on a token. Valid means we return a participant
invalid means we return None
'''
# A token that is finished or revoked is not valid
subid = None
if not token.endswith(('finished','revoked')):
subid = self.generate_subid(toke... | def validate_token(self, token):
'''retrieve a subject based on a token. Valid means we return a participant
invalid means we return None
'''
# A token that is finished or revoked is not valid
subid = None
if not token.endswith(('finished','revoked')):
subid = self.generate_subid(toke... | [
"retrieve",
"a",
"subject",
"based",
"on",
"a",
"token",
".",
"Valid",
"means",
"we",
"return",
"a",
"participant",
"invalid",
"means",
"we",
"return",
"None"
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/filesystem.py#L188-L199 | [
"def",
"validate_token",
"(",
"self",
",",
"token",
")",
":",
"# A token that is finished or revoked is not valid",
"subid",
"=",
"None",
"if",
"not",
"token",
".",
"endswith",
"(",
"(",
"'finished'",
",",
"'revoked'",
")",
")",
":",
"subid",
"=",
"self",
".",... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | refresh_token | refresh or generate a new token for a user. If the user is finished,
this will also make the folder available again for using. | expfactory/database/filesystem.py | def refresh_token(self, subid):
'''refresh or generate a new token for a user. If the user is finished,
this will also make the folder available again for using.'''
if os.path.exists(self.data_base): # /scif/data
data_base = "%s/%s" %(self.data_base, subid)
if os.path.exists(data_base)... | def refresh_token(self, subid):
'''refresh or generate a new token for a user. If the user is finished,
this will also make the folder available again for using.'''
if os.path.exists(self.data_base): # /scif/data
data_base = "%s/%s" %(self.data_base, subid)
if os.path.exists(data_base)... | [
"refresh",
"or",
"generate",
"a",
"new",
"token",
"for",
"a",
"user",
".",
"If",
"the",
"user",
"is",
"finished",
"this",
"will",
"also",
"make",
"the",
"folder",
"available",
"again",
"for",
"using",
"."
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/filesystem.py#L202-L213 | [
"def",
"refresh_token",
"(",
"self",
",",
"subid",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"data_base",
")",
":",
"# /scif/data",
"data_base",
"=",
"\"%s/%s\"",
"%",
"(",
"self",
".",
"data_base",
",",
"subid",
")",
"if",
... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | save_data | save data will obtain the current subid from the session, and save it
depending on the database type. Currently we just support flat files | expfactory/database/filesystem.py | def save_data(self, session, exp_id, content):
'''save data will obtain the current subid from the session, and save it
depending on the database type. Currently we just support flat files'''
subid = session.get('subid')
# We only attempt save if there is a subject id, set at start
data_file = ... | def save_data(self, session, exp_id, content):
'''save data will obtain the current subid from the session, and save it
depending on the database type. Currently we just support flat files'''
subid = session.get('subid')
# We only attempt save if there is a subject id, set at start
data_file = ... | [
"save",
"data",
"will",
"obtain",
"the",
"current",
"subid",
"from",
"the",
"session",
"and",
"save",
"it",
"depending",
"on",
"the",
"database",
"type",
".",
"Currently",
"we",
"just",
"support",
"flat",
"files"
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/filesystem.py#L221-L253 | [
"def",
"save_data",
"(",
"self",
",",
"session",
",",
"exp_id",
",",
"content",
")",
":",
"subid",
"=",
"session",
".",
"get",
"(",
"'subid'",
")",
"# We only attempt save if there is a subject id, set at start",
"data_file",
"=",
"None",
"if",
"subid",
"is",
"n... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | init_db | init_db for the filesystem ensures that the base folder (named
according to the studyid) exists. | expfactory/database/filesystem.py | def init_db(self):
'''init_db for the filesystem ensures that the base folder (named
according to the studyid) exists.
'''
self.session = None
if not os.path.exists(self.data_base):
mkdir_p(self.data_base)
self.database = "%s/%s" %(self.data_base, self.study_id)
if not os.path.... | def init_db(self):
'''init_db for the filesystem ensures that the base folder (named
according to the studyid) exists.
'''
self.session = None
if not os.path.exists(self.data_base):
mkdir_p(self.data_base)
self.database = "%s/%s" %(self.data_base, self.study_id)
if not os.path.... | [
"init_db",
"for",
"the",
"filesystem",
"ensures",
"that",
"the",
"base",
"folder",
"(",
"named",
"according",
"to",
"the",
"studyid",
")",
"exists",
"."
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/filesystem.py#L256-L267 | [
"def",
"init_db",
"(",
"self",
")",
":",
"self",
".",
"session",
"=",
"None",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"data_base",
")",
":",
"mkdir_p",
"(",
"self",
".",
"data_base",
")",
"self",
".",
"database",
"=",
"\"%s... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | native | Used as a decorator to add the decorated function to the
pfp interpreter so that it can be used from within scripts.
:param str name: The name of the function as it will be exposed in template scripts.
:param pfp.fields.Field ret: The return type of the function (a class)
:param pfp.interp.PfpInterp in... | pfp/native/__init__.py | def native(name, ret, interp=None, send_interp=False):
"""Used as a decorator to add the decorated function to the
pfp interpreter so that it can be used from within scripts.
:param str name: The name of the function as it will be exposed in template scripts.
:param pfp.fields.Field ret: The return typ... | def native(name, ret, interp=None, send_interp=False):
"""Used as a decorator to add the decorated function to the
pfp interpreter so that it can be used from within scripts.
:param str name: The name of the function as it will be exposed in template scripts.
:param pfp.fields.Field ret: The return typ... | [
"Used",
"as",
"a",
"decorator",
"to",
"add",
"the",
"decorated",
"function",
"to",
"the",
"pfp",
"interpreter",
"so",
"that",
"it",
"can",
"be",
"used",
"from",
"within",
"scripts",
"."
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/native/__init__.py#L5-L47 | [
"def",
"native",
"(",
"name",
",",
"ret",
",",
"interp",
"=",
"None",
",",
"send_interp",
"=",
"False",
")",
":",
"def",
"native_decorator",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"native_wrapper",
"(",
"*",
"... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | PfpDbg.do_peek | Peek at the next 16 bytes in the stream::
Example:
The peek command will display the next 16 hex bytes in the input
stream::
pfp> peek
89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 .PNG........IHDR | pfp/dbg.py | def do_peek(self, args):
"""Peek at the next 16 bytes in the stream::
Example:
The peek command will display the next 16 hex bytes in the input
stream::
pfp> peek
89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 .PNG........IHDR
"""
... | def do_peek(self, args):
"""Peek at the next 16 bytes in the stream::
Example:
The peek command will display the next 16 hex bytes in the input
stream::
pfp> peek
89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 .PNG........IHDR
"""
... | [
"Peek",
"at",
"the",
"next",
"16",
"bytes",
"in",
"the",
"stream",
"::"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/dbg.py#L59-L98 | [
"def",
"do_peek",
"(",
"self",
",",
"args",
")",
":",
"s",
"=",
"self",
".",
"_interp",
".",
"_stream",
"# make a copy of it",
"pos",
"=",
"s",
".",
"tell",
"(",
")",
"saved_bits",
"=",
"collections",
".",
"deque",
"(",
"s",
".",
"_bits",
")",
"data"... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | PfpDbg.do_next | Step over the next statement | pfp/dbg.py | def do_next(self, args):
"""Step over the next statement
"""
self._do_print_from_last_cmd = True
self._interp.step_over()
return True | def do_next(self, args):
"""Step over the next statement
"""
self._do_print_from_last_cmd = True
self._interp.step_over()
return True | [
"Step",
"over",
"the",
"next",
"statement"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/dbg.py#L100-L105 | [
"def",
"do_next",
"(",
"self",
",",
"args",
")",
":",
"self",
".",
"_do_print_from_last_cmd",
"=",
"True",
"self",
".",
"_interp",
".",
"step_over",
"(",
")",
"return",
"True"
] | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | PfpDbg.do_step | Step INTO the next statement | pfp/dbg.py | def do_step(self, args):
"""Step INTO the next statement
"""
self._do_print_from_last_cmd = True
self._interp.step_into()
return True | def do_step(self, args):
"""Step INTO the next statement
"""
self._do_print_from_last_cmd = True
self._interp.step_into()
return True | [
"Step",
"INTO",
"the",
"next",
"statement"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/dbg.py#L107-L112 | [
"def",
"do_step",
"(",
"self",
",",
"args",
")",
":",
"self",
".",
"_do_print_from_last_cmd",
"=",
"True",
"self",
".",
"_interp",
".",
"step_into",
"(",
")",
"return",
"True"
] | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | PfpDbg.do_continue | Continue the interpreter | pfp/dbg.py | def do_continue(self, args):
"""Continue the interpreter
"""
self._do_print_from_last_cmd = True
self._interp.cont()
return True | def do_continue(self, args):
"""Continue the interpreter
"""
self._do_print_from_last_cmd = True
self._interp.cont()
return True | [
"Continue",
"the",
"interpreter"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/dbg.py#L119-L124 | [
"def",
"do_continue",
"(",
"self",
",",
"args",
")",
":",
"self",
".",
"_do_print_from_last_cmd",
"=",
"True",
"self",
".",
"_interp",
".",
"cont",
"(",
")",
"return",
"True"
] | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | PfpDbg.do_eval | Eval the user-supplied statement. Note that you can do anything with
this command that you can do in a template.
The resulting value of your statement will be displayed. | pfp/dbg.py | def do_eval(self, args):
"""Eval the user-supplied statement. Note that you can do anything with
this command that you can do in a template.
The resulting value of your statement will be displayed.
"""
try:
res = self._interp.eval(args)
if res is not None... | def do_eval(self, args):
"""Eval the user-supplied statement. Note that you can do anything with
this command that you can do in a template.
The resulting value of your statement will be displayed.
"""
try:
res = self._interp.eval(args)
if res is not None... | [
"Eval",
"the",
"user",
"-",
"supplied",
"statement",
".",
"Note",
"that",
"you",
"can",
"do",
"anything",
"with",
"this",
"command",
"that",
"you",
"can",
"do",
"in",
"a",
"template",
"."
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/dbg.py#L126-L145 | [
"def",
"do_eval",
"(",
"self",
",",
"args",
")",
":",
"try",
":",
"res",
"=",
"self",
".",
"_interp",
".",
"eval",
"(",
"args",
")",
"if",
"res",
"is",
"not",
"None",
":",
"if",
"hasattr",
"(",
"res",
",",
"\"_pfp__show\"",
")",
":",
"print",
"("... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | PfpDbg.do_show | Show the current structure of __root (no args),
or show the result of the expression (something that can be eval'd). | pfp/dbg.py | def do_show(self, args):
"""Show the current structure of __root (no args),
or show the result of the expression (something that can be eval'd).
"""
args = args.strip()
to_show = self._interp._root
if args != "":
try:
to_show = self._interp.ev... | def do_show(self, args):
"""Show the current structure of __root (no args),
or show the result of the expression (something that can be eval'd).
"""
args = args.strip()
to_show = self._interp._root
if args != "":
try:
to_show = self._interp.ev... | [
"Show",
"the",
"current",
"structure",
"of",
"__root",
"(",
"no",
"args",
")",
"or",
"show",
"the",
"result",
"of",
"the",
"expression",
"(",
"something",
"that",
"can",
"be",
"eval",
"d",
")",
"."
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/dbg.py#L147-L164 | [
"def",
"do_show",
"(",
"self",
",",
"args",
")",
":",
"args",
"=",
"args",
".",
"strip",
"(",
")",
"to_show",
"=",
"self",
".",
"_interp",
".",
"_root",
"if",
"args",
"!=",
"\"\"",
":",
"try",
":",
"to_show",
"=",
"self",
".",
"_interp",
".",
"ev... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | PfpDbg.do_quit | The quit command | pfp/dbg.py | def do_quit(self, args):
"""The quit command
"""
self._interp.set_break(self._interp.BREAK_NONE)
return True | def do_quit(self, args):
"""The quit command
"""
self._interp.set_break(self._interp.BREAK_NONE)
return True | [
"The",
"quit",
"command"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/dbg.py#L175-L179 | [
"def",
"do_quit",
"(",
"self",
",",
"args",
")",
":",
"self",
".",
"_interp",
".",
"set_break",
"(",
"self",
".",
"_interp",
".",
"BREAK_NONE",
")",
"return",
"True"
] | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | RuntimeValidator.validate | takes in a Github repository for validation of preview and
runtime (and possibly tests passing? | expfactory/validator/runtime.py | def validate(self, url):
''' takes in a Github repository for validation of preview and
runtime (and possibly tests passing?
'''
# Preview must provide the live URL of the repository
if not url.startswith('http') or not 'github' in url:
bot.error('Test of previe... | def validate(self, url):
''' takes in a Github repository for validation of preview and
runtime (and possibly tests passing?
'''
# Preview must provide the live URL of the repository
if not url.startswith('http') or not 'github' in url:
bot.error('Test of previe... | [
"takes",
"in",
"a",
"Github",
"repository",
"for",
"validation",
"of",
"preview",
"and",
"runtime",
"(",
"and",
"possibly",
"tests",
"passing?"
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/validator/runtime.py#L50-L63 | [
"def",
"validate",
"(",
"self",
",",
"url",
")",
":",
"# Preview must provide the live URL of the repository",
"if",
"not",
"url",
".",
"startswith",
"(",
"'http'",
")",
"or",
"not",
"'github'",
"in",
"url",
":",
"bot",
".",
"error",
"(",
"'Test of preview must ... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | mask_dict_password | Replace passwords with a secret in a dictionary. | virtualbmc/utils.py | def mask_dict_password(dictionary, secret='***'):
"""Replace passwords with a secret in a dictionary."""
d = dictionary.copy()
for k in d:
if 'password' in k:
d[k] = secret
return d | def mask_dict_password(dictionary, secret='***'):
"""Replace passwords with a secret in a dictionary."""
d = dictionary.copy()
for k in d:
if 'password' in k:
d[k] = secret
return d | [
"Replace",
"passwords",
"with",
"a",
"secret",
"in",
"a",
"dictionary",
"."
] | umago/virtualbmc | python | https://github.com/umago/virtualbmc/blob/47551d1427e8976da0449c5405e87a763180ad1a/virtualbmc/utils.py#L90-L96 | [
"def",
"mask_dict_password",
"(",
"dictionary",
",",
"secret",
"=",
"'***'",
")",
":",
"d",
"=",
"dictionary",
".",
"copy",
"(",
")",
"for",
"k",
"in",
"d",
":",
"if",
"'password'",
"in",
"k",
":",
"d",
"[",
"k",
"]",
"=",
"secret",
"return",
"d"
] | 47551d1427e8976da0449c5405e87a763180ad1a |
train | save | save is a view to save data. We might want to adjust this to allow for
updating saved data, but given single file is just one post for now | expfactory/views/main.py | def save():
'''save is a view to save data. We might want to adjust this to allow for
updating saved data, but given single file is just one post for now
'''
if request.method == 'POST':
exp_id = session.get('exp_id')
app.logger.debug('Saving data for %s' %exp_id)
fields = ge... | def save():
'''save is a view to save data. We might want to adjust this to allow for
updating saved data, but given single file is just one post for now
'''
if request.method == 'POST':
exp_id = session.get('exp_id')
app.logger.debug('Saving data for %s' %exp_id)
fields = ge... | [
"save",
"is",
"a",
"view",
"to",
"save",
"data",
".",
"We",
"might",
"want",
"to",
"adjust",
"this",
"to",
"allow",
"for",
"updating",
"saved",
"data",
"but",
"given",
"single",
"file",
"is",
"just",
"one",
"post",
"for",
"now"
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/views/main.py#L110-L126 | [
"def",
"save",
"(",
")",
":",
"if",
"request",
".",
"method",
"==",
"'POST'",
":",
"exp_id",
"=",
"session",
".",
"get",
"(",
"'exp_id'",
")",
"app",
".",
"logger",
".",
"debug",
"(",
"'Saving data for %s'",
"%",
"exp_id",
")",
"fields",
"=",
"get_post... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | main | this is the main entrypoint for a container based web server, with
most of the variables coming from the environment. See the Dockerfile
template for how this function is executed. | expfactory/cli/main.py | def main(args,parser,subparser=None):
'''this is the main entrypoint for a container based web server, with
most of the variables coming from the environment. See the Dockerfile
template for how this function is executed.
'''
# First priority to args.base
base = args.base
if base is ... | def main(args,parser,subparser=None):
'''this is the main entrypoint for a container based web server, with
most of the variables coming from the environment. See the Dockerfile
template for how this function is executed.
'''
# First priority to args.base
base = args.base
if base is ... | [
"this",
"is",
"the",
"main",
"entrypoint",
"for",
"a",
"container",
"based",
"web",
"server",
"with",
"most",
"of",
"the",
"variables",
"coming",
"from",
"the",
"environment",
".",
"See",
"the",
"Dockerfile",
"template",
"for",
"how",
"this",
"function",
"is... | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/cli/main.py#L40-L86 | [
"def",
"main",
"(",
"args",
",",
"parser",
",",
"subparser",
"=",
"None",
")",
":",
"# First priority to args.base",
"base",
"=",
"args",
".",
"base",
"if",
"base",
"is",
"None",
":",
"base",
"=",
"os",
".",
"environ",
".",
"get",
"(",
"'EXPFACTORY_BASE'... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | save_data | save data will obtain the current subid from the session, and save it
depending on the database type. | expfactory/database/sqlite.py | def save_data(self,session, exp_id, content):
'''save data will obtain the current subid from the session, and save it
depending on the database type.'''
from expfactory.database.models import (
Participant,
Result
)
subid = session.get('subid')
bot.info('Saving data for subi... | def save_data(self,session, exp_id, content):
'''save data will obtain the current subid from the session, and save it
depending on the database type.'''
from expfactory.database.models import (
Participant,
Result
)
subid = session.get('subid')
bot.info('Saving data for subi... | [
"save",
"data",
"will",
"obtain",
"the",
"current",
"subid",
"from",
"the",
"session",
"and",
"save",
"it",
"depending",
"on",
"the",
"database",
"type",
"."
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/sqlite.py#L62-L91 | [
"def",
"save_data",
"(",
"self",
",",
"session",
",",
"exp_id",
",",
"content",
")",
":",
"from",
"expfactory",
".",
"database",
".",
"models",
"import",
"(",
"Participant",
",",
"Result",
")",
"subid",
"=",
"session",
".",
"get",
"(",
"'subid'",
")",
... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | init_db | initialize the database, with the default database path or custom of
the format sqlite:////scif/data/expfactory.db | expfactory/database/sqlite.py | def init_db(self):
'''initialize the database, with the default database path or custom of
the format sqlite:////scif/data/expfactory.db
'''
# Database Setup, use default if uri not provided
if self.database == 'sqlite':
db_path = os.path.join(EXPFACTORY_DATA, '%s.db' % EXPFACTORY_SUBID... | def init_db(self):
'''initialize the database, with the default database path or custom of
the format sqlite:////scif/data/expfactory.db
'''
# Database Setup, use default if uri not provided
if self.database == 'sqlite':
db_path = os.path.join(EXPFACTORY_DATA, '%s.db' % EXPFACTORY_SUBID... | [
"initialize",
"the",
"database",
"with",
"the",
"default",
"database",
"path",
"or",
"custom",
"of",
"the",
"format",
"sqlite",
":",
"////",
"scif",
"/",
"data",
"/",
"expfactory",
".",
"db"
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/sqlite.py#L96-L120 | [
"def",
"init_db",
"(",
"self",
")",
":",
"# Database Setup, use default if uri not provided",
"if",
"self",
".",
"database",
"==",
"'sqlite'",
":",
"db_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"EXPFACTORY_DATA",
",",
"'%s.db'",
"%",
"EXPFACTORY_SUBID",
"... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | BitfieldRW.reserve_bits | Used to "reserve" ``num_bits`` amount of bits in order to keep track
of consecutive bitfields (or are the called bitfield groups?).
E.g. ::
struct {
char a:8, b:8;
char c:4, d:4, e:8;
}
:param int num_bits: The number of bits to claim
... | pfp/fields.py | def reserve_bits(self, num_bits, stream):
"""Used to "reserve" ``num_bits`` amount of bits in order to keep track
of consecutive bitfields (or are the called bitfield groups?).
E.g. ::
struct {
char a:8, b:8;
char c:4, d:4, e:8;
}
... | def reserve_bits(self, num_bits, stream):
"""Used to "reserve" ``num_bits`` amount of bits in order to keep track
of consecutive bitfields (or are the called bitfield groups?).
E.g. ::
struct {
char a:8, b:8;
char c:4, d:4, e:8;
}
... | [
"Used",
"to",
"reserve",
"num_bits",
"amount",
"of",
"bits",
"in",
"order",
"to",
"keep",
"track",
"of",
"consecutive",
"bitfields",
"(",
"or",
"are",
"the",
"called",
"bitfield",
"groups?",
")",
"."
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L73-L109 | [
"def",
"reserve_bits",
"(",
"self",
",",
"num_bits",
",",
"stream",
")",
":",
"padded",
"=",
"self",
".",
"interp",
".",
"get_bitfield_padded",
"(",
")",
"num_bits",
"=",
"PYVAL",
"(",
"num_bits",
")",
"if",
"padded",
":",
"num_bits",
"=",
"PYVAL",
"(",
... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | BitfieldRW.read_bits | Return ``num_bits`` bits, taking into account endianness and
left-right bit directions | pfp/fields.py | def read_bits(self, stream, num_bits, padded, left_right, endian):
"""Return ``num_bits`` bits, taking into account endianness and
left-right bit directions
"""
if self._cls_bits is None and padded:
raw_bits = stream.read_bits(self.cls.width*8)
self._cls_bits = s... | def read_bits(self, stream, num_bits, padded, left_right, endian):
"""Return ``num_bits`` bits, taking into account endianness and
left-right bit directions
"""
if self._cls_bits is None and padded:
raw_bits = stream.read_bits(self.cls.width*8)
self._cls_bits = s... | [
"Return",
"num_bits",
"bits",
"taking",
"into",
"account",
"endianness",
"and",
"left",
"-",
"right",
"bit",
"directions"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L111-L133 | [
"def",
"read_bits",
"(",
"self",
",",
"stream",
",",
"num_bits",
",",
"padded",
",",
"left_right",
",",
"endian",
")",
":",
"if",
"self",
".",
"_cls_bits",
"is",
"None",
"and",
"padded",
":",
"raw_bits",
"=",
"stream",
".",
"read_bits",
"(",
"self",
".... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | BitfieldRW.write_bits | Write the bits. Once the size of the written bits is equal
to the number of the reserved bits, flush it to the stream | pfp/fields.py | def write_bits(self, stream, raw_bits, padded, left_right, endian):
"""Write the bits. Once the size of the written bits is equal
to the number of the reserved bits, flush it to the stream
"""
if padded:
if left_right:
self._write_bits += raw_bits
... | def write_bits(self, stream, raw_bits, padded, left_right, endian):
"""Write the bits. Once the size of the written bits is equal
to the number of the reserved bits, flush it to the stream
"""
if padded:
if left_right:
self._write_bits += raw_bits
... | [
"Write",
"the",
"bits",
".",
"Once",
"the",
"size",
"of",
"the",
"written",
"bits",
"is",
"equal",
"to",
"the",
"number",
"of",
"the",
"reserved",
"bits",
"flush",
"it",
"to",
"the",
"stream"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L135-L170 | [
"def",
"write_bits",
"(",
"self",
",",
"stream",
",",
"raw_bits",
",",
"padded",
",",
"left_right",
",",
"endian",
")",
":",
"if",
"padded",
":",
"if",
"left_right",
":",
"self",
".",
"_write_bits",
"+=",
"raw_bits",
"else",
":",
"self",
".",
"_write_bit... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Field._pfp__snapshot | Save off the current value of the field | pfp/fields.py | def _pfp__snapshot(self, recurse=True):
"""Save off the current value of the field
"""
if hasattr(self, "_pfp__value"):
self._pfp__snapshot_value = self._pfp__value | def _pfp__snapshot(self, recurse=True):
"""Save off the current value of the field
"""
if hasattr(self, "_pfp__value"):
self._pfp__snapshot_value = self._pfp__value | [
"Save",
"off",
"the",
"current",
"value",
"of",
"the",
"field"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L236-L240 | [
"def",
"_pfp__snapshot",
"(",
"self",
",",
"recurse",
"=",
"True",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"\"_pfp__value\"",
")",
":",
"self",
".",
"_pfp__snapshot_value",
"=",
"self",
".",
"_pfp__value"
] | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Field._pfp__process_metadata | Process the metadata once the entire struct has been
declared. | pfp/fields.py | def _pfp__process_metadata(self):
"""Process the metadata once the entire struct has been
declared.
"""
if self._pfp__metadata_processor is None:
return
metadata_info = self._pfp__metadata_processor()
if isinstance(metadata_info, list):
for metada... | def _pfp__process_metadata(self):
"""Process the metadata once the entire struct has been
declared.
"""
if self._pfp__metadata_processor is None:
return
metadata_info = self._pfp__metadata_processor()
if isinstance(metadata_info, list):
for metada... | [
"Process",
"the",
"metadata",
"once",
"the",
"entire",
"struct",
"has",
"been",
"declared",
"."
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L247-L268 | [
"def",
"_pfp__process_metadata",
"(",
"self",
")",
":",
"if",
"self",
".",
"_pfp__metadata_processor",
"is",
"None",
":",
"return",
"metadata_info",
"=",
"self",
".",
"_pfp__metadata_processor",
"(",
")",
"if",
"isinstance",
"(",
"metadata_info",
",",
"list",
")... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Field._pfp__watch | Add the watcher to the list of fields that
are watching this field | pfp/fields.py | def _pfp__watch(self, watcher):
"""Add the watcher to the list of fields that
are watching this field
"""
if self._pfp__parent is not None and isinstance(self._pfp__parent, Union):
self._pfp__parent._pfp__watch(watcher)
else:
self._pfp__watchers.append(wat... | def _pfp__watch(self, watcher):
"""Add the watcher to the list of fields that
are watching this field
"""
if self._pfp__parent is not None and isinstance(self._pfp__parent, Union):
self._pfp__parent._pfp__watch(watcher)
else:
self._pfp__watchers.append(wat... | [
"Add",
"the",
"watcher",
"to",
"the",
"list",
"of",
"fields",
"that",
"are",
"watching",
"this",
"field"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L270-L277 | [
"def",
"_pfp__watch",
"(",
"self",
",",
"watcher",
")",
":",
"if",
"self",
".",
"_pfp__parent",
"is",
"not",
"None",
"and",
"isinstance",
"(",
"self",
".",
"_pfp__parent",
",",
"Union",
")",
":",
"self",
".",
"_pfp__parent",
".",
"_pfp__watch",
"(",
"wat... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Field._pfp__set_watch | Subscribe to update events on each field in ``watch_fields``, using
``update_func`` to update self's value when ``watch_field``
changes | pfp/fields.py | def _pfp__set_watch(self, watch_fields, update_func, *func_call_info):
"""Subscribe to update events on each field in ``watch_fields``, using
``update_func`` to update self's value when ``watch_field``
changes"""
self._pfp__watch_fields = watch_fields
for watch_field in watch_fi... | def _pfp__set_watch(self, watch_fields, update_func, *func_call_info):
"""Subscribe to update events on each field in ``watch_fields``, using
``update_func`` to update self's value when ``watch_field``
changes"""
self._pfp__watch_fields = watch_fields
for watch_field in watch_fi... | [
"Subscribe",
"to",
"update",
"events",
"on",
"each",
"field",
"in",
"watch_fields",
"using",
"update_func",
"to",
"update",
"self",
"s",
"value",
"when",
"watch_field",
"changes"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L279-L288 | [
"def",
"_pfp__set_watch",
"(",
"self",
",",
"watch_fields",
",",
"update_func",
",",
"*",
"func_call_info",
")",
":",
"self",
".",
"_pfp__watch_fields",
"=",
"watch_fields",
"for",
"watch_field",
"in",
"watch_fields",
":",
"watch_field",
".",
"_pfp__watch",
"(",
... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Field._pfp__set_packer | Set the packer/pack/unpack functions for this field, as
well as the pack type.
:pack_type: The data type of the packed data
:packer: A function that can handle packing and unpacking. First
arg is true/false (to pack or unpack). Second arg is the stream.
Must re... | pfp/fields.py | def _pfp__set_packer(self, pack_type, packer=None, pack=None, unpack=None, func_call_info=None):
"""Set the packer/pack/unpack functions for this field, as
well as the pack type.
:pack_type: The data type of the packed data
:packer: A function that can handle packing and unpacking. Firs... | def _pfp__set_packer(self, pack_type, packer=None, pack=None, unpack=None, func_call_info=None):
"""Set the packer/pack/unpack functions for this field, as
well as the pack type.
:pack_type: The data type of the packed data
:packer: A function that can handle packing and unpacking. Firs... | [
"Set",
"the",
"packer",
"/",
"pack",
"/",
"unpack",
"functions",
"for",
"this",
"field",
"as",
"well",
"as",
"the",
"pack",
"type",
"."
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L290-L307 | [
"def",
"_pfp__set_packer",
"(",
"self",
",",
"pack_type",
",",
"packer",
"=",
"None",
",",
"pack",
"=",
"None",
",",
"unpack",
"=",
"None",
",",
"func_call_info",
"=",
"None",
")",
":",
"self",
".",
"_pfp__pack_type",
"=",
"pack_type",
"self",
".",
"_pfp... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Field._pfp__pack_data | Pack the nested field | pfp/fields.py | def _pfp__pack_data(self):
"""Pack the nested field
"""
if self._pfp__pack_type is None:
return
tmp_stream = six.BytesIO()
self._._pfp__build(bitwrap.BitwrappedStream(tmp_stream))
raw_data = tmp_stream.getvalue()
unpack_func = self._pfp__packer
... | def _pfp__pack_data(self):
"""Pack the nested field
"""
if self._pfp__pack_type is None:
return
tmp_stream = six.BytesIO()
self._._pfp__build(bitwrap.BitwrappedStream(tmp_stream))
raw_data = tmp_stream.getvalue()
unpack_func = self._pfp__packer
... | [
"Pack",
"the",
"nested",
"field"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L309-L342 | [
"def",
"_pfp__pack_data",
"(",
"self",
")",
":",
"if",
"self",
".",
"_pfp__pack_type",
"is",
"None",
":",
"return",
"tmp_stream",
"=",
"six",
".",
"BytesIO",
"(",
")",
"self",
".",
"_",
".",
"_pfp__build",
"(",
"bitwrap",
".",
"BitwrappedStream",
"(",
"t... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Field._pfp__unpack_data | Means that the field has already been parsed normally,
and that it now needs to be unpacked.
:raw_data: A string of the data that the field consumed while parsing | pfp/fields.py | def _pfp__unpack_data(self, raw_data):
"""Means that the field has already been parsed normally,
and that it now needs to be unpacked.
:raw_data: A string of the data that the field consumed while parsing
"""
if self._pfp__pack_type is None:
return
if self._p... | def _pfp__unpack_data(self, raw_data):
"""Means that the field has already been parsed normally,
and that it now needs to be unpacked.
:raw_data: A string of the data that the field consumed while parsing
"""
if self._pfp__pack_type is None:
return
if self._p... | [
"Means",
"that",
"the",
"field",
"has",
"already",
"been",
"parsed",
"normally",
"and",
"that",
"it",
"now",
"needs",
"to",
"be",
"unpacked",
"."
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L350-L387 | [
"def",
"_pfp__unpack_data",
"(",
"self",
",",
"raw_data",
")",
":",
"if",
"self",
".",
"_pfp__pack_type",
"is",
"None",
":",
"return",
"if",
"self",
".",
"_pfp__no_unpack",
":",
"return",
"unpack_func",
"=",
"self",
".",
"_pfp__packer",
"unpack_args",
"=",
"... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Field._pfp__handle_updated | Handle the watched field that was updated | pfp/fields.py | def _pfp__handle_updated(self, watched_field):
"""Handle the watched field that was updated
"""
self._pfp__no_notify = True
# nested data has been changed, so rebuild the
# nested data to update the field
# TODO a global setting to determine this behavior?
# coul... | def _pfp__handle_updated(self, watched_field):
"""Handle the watched field that was updated
"""
self._pfp__no_notify = True
# nested data has been changed, so rebuild the
# nested data to update the field
# TODO a global setting to determine this behavior?
# coul... | [
"Handle",
"the",
"watched",
"field",
"that",
"was",
"updated"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L395-L415 | [
"def",
"_pfp__handle_updated",
"(",
"self",
",",
"watched_field",
")",
":",
"self",
".",
"_pfp__no_notify",
"=",
"True",
"# nested data has been changed, so rebuild the",
"# nested data to update the field",
"# TODO a global setting to determine this behavior?",
"# could slow things ... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Field._pfp__width | Return the width of the field (sizeof) | pfp/fields.py | def _pfp__width(self):
"""Return the width of the field (sizeof)
"""
raw_output = six.BytesIO()
output = bitwrap.BitwrappedStream(raw_output)
self._pfp__build(output)
output.flush()
return len(raw_output.getvalue()) | def _pfp__width(self):
"""Return the width of the field (sizeof)
"""
raw_output = six.BytesIO()
output = bitwrap.BitwrappedStream(raw_output)
self._pfp__build(output)
output.flush()
return len(raw_output.getvalue()) | [
"Return",
"the",
"width",
"of",
"the",
"field",
"(",
"sizeof",
")"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L423-L430 | [
"def",
"_pfp__width",
"(",
"self",
")",
":",
"raw_output",
"=",
"six",
".",
"BytesIO",
"(",
")",
"output",
"=",
"bitwrap",
".",
"BitwrappedStream",
"(",
"raw_output",
")",
"self",
".",
"_pfp__build",
"(",
"output",
")",
"output",
".",
"flush",
"(",
")",
... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Field._pfp__set_value | Set the new value if type checking is passes, potentially
(TODO? reevaluate this) casting the value to something else
:new_val: The new value
:returns: TODO | pfp/fields.py | def _pfp__set_value(self, new_val):
"""Set the new value if type checking is passes, potentially
(TODO? reevaluate this) casting the value to something else
:new_val: The new value
:returns: TODO
"""
if self._pfp__frozen:
raise errors.UnmodifiableConst()
... | def _pfp__set_value(self, new_val):
"""Set the new value if type checking is passes, potentially
(TODO? reevaluate this) casting the value to something else
:new_val: The new value
:returns: TODO
"""
if self._pfp__frozen:
raise errors.UnmodifiableConst()
... | [
"Set",
"the",
"new",
"value",
"if",
"type",
"checking",
"is",
"passes",
"potentially",
"(",
"TODO?",
"reevaluate",
"this",
")",
"casting",
"the",
"value",
"to",
"something",
"else"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L444-L455 | [
"def",
"_pfp__set_value",
"(",
"self",
",",
"new_val",
")",
":",
"if",
"self",
".",
"_pfp__frozen",
":",
"raise",
"errors",
".",
"UnmodifiableConst",
"(",
")",
"self",
".",
"_pfp__value",
"=",
"self",
".",
"_pfp__get_root_value",
"(",
"new_val",
")",
"self",... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Struct._pfp__snapshot | Save off the current value of the field | pfp/fields.py | def _pfp__snapshot(self, recurse=True):
"""Save off the current value of the field
"""
super(Struct, self)._pfp__snapshot(recurse=recurse)
if recurse:
for child in self._pfp__children:
child._pfp__snapshot(recurse=recurse) | def _pfp__snapshot(self, recurse=True):
"""Save off the current value of the field
"""
super(Struct, self)._pfp__snapshot(recurse=recurse)
if recurse:
for child in self._pfp__children:
child._pfp__snapshot(recurse=recurse) | [
"Save",
"off",
"the",
"current",
"value",
"of",
"the",
"field"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L603-L610 | [
"def",
"_pfp__snapshot",
"(",
"self",
",",
"recurse",
"=",
"True",
")",
":",
"super",
"(",
"Struct",
",",
"self",
")",
".",
"_pfp__snapshot",
"(",
"recurse",
"=",
"recurse",
")",
"if",
"recurse",
":",
"for",
"child",
"in",
"self",
".",
"_pfp__children",
... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Struct._pfp__restore_snapshot | Restore the snapshotted value without triggering any events | pfp/fields.py | def _pfp__restore_snapshot(self, recurse=True):
"""Restore the snapshotted value without triggering any events
"""
super(Struct, self)._pfp__restore_snapshot(recurse=recurse)
if recurse:
for child in self._pfp__children:
child._pfp__restore_snapshot(recurse=r... | def _pfp__restore_snapshot(self, recurse=True):
"""Restore the snapshotted value without triggering any events
"""
super(Struct, self)._pfp__restore_snapshot(recurse=recurse)
if recurse:
for child in self._pfp__children:
child._pfp__restore_snapshot(recurse=r... | [
"Restore",
"the",
"snapshotted",
"value",
"without",
"triggering",
"any",
"events"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L612-L619 | [
"def",
"_pfp__restore_snapshot",
"(",
"self",
",",
"recurse",
"=",
"True",
")",
":",
"super",
"(",
"Struct",
",",
"self",
")",
".",
"_pfp__restore_snapshot",
"(",
"recurse",
"=",
"recurse",
")",
"if",
"recurse",
":",
"for",
"child",
"in",
"self",
".",
"_... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Struct._pfp__set_value | Initialize the struct. Value should be an array of
fields, one each for each struct member.
:value: An array of fields to initialize the struct with
:returns: None | pfp/fields.py | def _pfp__set_value(self, value):
"""Initialize the struct. Value should be an array of
fields, one each for each struct member.
:value: An array of fields to initialize the struct with
:returns: None
"""
if self._pfp__frozen:
raise errors.UnmodifiableConst()... | def _pfp__set_value(self, value):
"""Initialize the struct. Value should be an array of
fields, one each for each struct member.
:value: An array of fields to initialize the struct with
:returns: None
"""
if self._pfp__frozen:
raise errors.UnmodifiableConst()... | [
"Initialize",
"the",
"struct",
".",
"Value",
"should",
"be",
"an",
"array",
"of",
"fields",
"one",
"each",
"for",
"each",
"struct",
"member",
"."
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L627-L640 | [
"def",
"_pfp__set_value",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"_pfp__frozen",
":",
"raise",
"errors",
".",
"UnmodifiableConst",
"(",
")",
"if",
"len",
"(",
"value",
")",
"!=",
"len",
"(",
"self",
".",
"_pfp__children",
")",
":",
"ra... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Struct._pfp__add_child | Add a child to the Struct field. If multiple consecutive fields are
added with the same name, an implicit array will be created to store
all fields of that name.
:param str name: The name of the child
:param pfp.fields.Field child: The field to add
:param bool overwrite: Overwri... | pfp/fields.py | def _pfp__add_child(self, name, child, stream=None, overwrite=False):
"""Add a child to the Struct field. If multiple consecutive fields are
added with the same name, an implicit array will be created to store
all fields of that name.
:param str name: The name of the child
:para... | def _pfp__add_child(self, name, child, stream=None, overwrite=False):
"""Add a child to the Struct field. If multiple consecutive fields are
added with the same name, an implicit array will be created to store
all fields of that name.
:param str name: The name of the child
:para... | [
"Add",
"a",
"child",
"to",
"the",
"Struct",
"field",
".",
"If",
"multiple",
"consecutive",
"fields",
"are",
"added",
"with",
"the",
"same",
"name",
"an",
"implicit",
"array",
"will",
"be",
"created",
"to",
"store",
"all",
"fields",
"of",
"that",
"name",
... | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L642-L662 | [
"def",
"_pfp__add_child",
"(",
"self",
",",
"name",
",",
"child",
",",
"stream",
"=",
"None",
",",
"overwrite",
"=",
"False",
")",
":",
"if",
"not",
"overwrite",
"and",
"self",
".",
"_pfp__is_non_consecutive_duplicate",
"(",
"name",
",",
"child",
")",
":",... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Struct._pfp__handle_non_consecutive_duplicate | This new child, and potentially one already existing child, need to
have a numeric suffix appended to their name.
An entry will be made for this name in ``self._pfp__name_collisions`` to keep
track of the next available suffix number | pfp/fields.py | def _pfp__handle_non_consecutive_duplicate(self, name, child, insert=True):
"""This new child, and potentially one already existing child, need to
have a numeric suffix appended to their name.
An entry will be made for this name in ``self._pfp__name_collisions`` to keep
track of... | def _pfp__handle_non_consecutive_duplicate(self, name, child, insert=True):
"""This new child, and potentially one already existing child, need to
have a numeric suffix appended to their name.
An entry will be made for this name in ``self._pfp__name_collisions`` to keep
track of... | [
"This",
"new",
"child",
"and",
"potentially",
"one",
"already",
"existing",
"child",
"need",
"to",
"have",
"a",
"numeric",
"suffix",
"appended",
"to",
"their",
"name",
".",
"An",
"entry",
"will",
"be",
"made",
"for",
"this",
"name",
"in",
"self",
".",
"_... | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L664-L689 | [
"def",
"_pfp__handle_non_consecutive_duplicate",
"(",
"self",
",",
"name",
",",
"child",
",",
"insert",
"=",
"True",
")",
":",
"if",
"name",
"in",
"self",
".",
"_pfp__children_map",
":",
"previous_child",
"=",
"self",
".",
"_pfp__children_map",
"[",
"name",
"]... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Struct._pfp__is_non_consecutive_duplicate | Return True/False if the child is a non-consecutive duplicately named
field. Consecutive duplicately-named fields are stored in an implicit array,
non-consecutive duplicately named fields have a numeric suffix appended to their name | pfp/fields.py | def _pfp__is_non_consecutive_duplicate(self, name, child):
"""Return True/False if the child is a non-consecutive duplicately named
field. Consecutive duplicately-named fields are stored in an implicit array,
non-consecutive duplicately named fields have a numeric suffix appended to their name""... | def _pfp__is_non_consecutive_duplicate(self, name, child):
"""Return True/False if the child is a non-consecutive duplicately named
field. Consecutive duplicately-named fields are stored in an implicit array,
non-consecutive duplicately named fields have a numeric suffix appended to their name""... | [
"Return",
"True",
"/",
"False",
"if",
"the",
"child",
"is",
"a",
"non",
"-",
"consecutive",
"duplicately",
"named",
"field",
".",
"Consecutive",
"duplicately",
"-",
"named",
"fields",
"are",
"stored",
"in",
"an",
"implicit",
"array",
"non",
"-",
"consecutive... | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L691-L710 | [
"def",
"_pfp__is_non_consecutive_duplicate",
"(",
"self",
",",
"name",
",",
"child",
")",
":",
"if",
"len",
"(",
"self",
".",
"_pfp__children",
")",
"==",
"0",
":",
"return",
"False",
"# it should be an implicit array",
"if",
"self",
".",
"_pfp__children",
"[",
... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Struct._pfp__handle_implicit_array | Handle inserting implicit array elements | pfp/fields.py | def _pfp__handle_implicit_array(self, name, child):
"""Handle inserting implicit array elements
"""
existing_child = self._pfp__children_map[name]
if isinstance(existing_child, Array):
# I don't think we should check this
#
#if existing_child.field_cls... | def _pfp__handle_implicit_array(self, name, child):
"""Handle inserting implicit array elements
"""
existing_child = self._pfp__children_map[name]
if isinstance(existing_child, Array):
# I don't think we should check this
#
#if existing_child.field_cls... | [
"Handle",
"inserting",
"implicit",
"array",
"elements"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L712-L742 | [
"def",
"_pfp__handle_implicit_array",
"(",
"self",
",",
"name",
",",
"child",
")",
":",
"existing_child",
"=",
"self",
".",
"_pfp__children_map",
"[",
"name",
"]",
"if",
"isinstance",
"(",
"existing_child",
",",
"Array",
")",
":",
"# I don't think we should check ... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Struct._pfp__parse | Parse the incoming stream
:stream: Input stream to be parsed
:returns: Number of bytes parsed | pfp/fields.py | def _pfp__parse(self, stream, save_offset=False):
"""Parse the incoming stream
:stream: Input stream to be parsed
:returns: Number of bytes parsed
"""
if save_offset:
self._pfp__offset = stream.tell()
res = 0
for child in self._pfp__children:
... | def _pfp__parse(self, stream, save_offset=False):
"""Parse the incoming stream
:stream: Input stream to be parsed
:returns: Number of bytes parsed
"""
if save_offset:
self._pfp__offset = stream.tell()
res = 0
for child in self._pfp__children:
... | [
"Parse",
"the",
"incoming",
"stream"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L744-L757 | [
"def",
"_pfp__parse",
"(",
"self",
",",
"stream",
",",
"save_offset",
"=",
"False",
")",
":",
"if",
"save_offset",
":",
"self",
".",
"_pfp__offset",
"=",
"stream",
".",
"tell",
"(",
")",
"res",
"=",
"0",
"for",
"child",
"in",
"self",
".",
"_pfp__childr... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Struct._pfp__build | Build the field and write the result into the stream
:stream: An IO stream that can be written to
:returns: None | pfp/fields.py | def _pfp__build(self, stream=None, save_offset=False):
"""Build the field and write the result into the stream
:stream: An IO stream that can be written to
:returns: None
"""
if save_offset and stream is not None:
self._pfp__offset = stream.tell()
# returns... | def _pfp__build(self, stream=None, save_offset=False):
"""Build the field and write the result into the stream
:stream: An IO stream that can be written to
:returns: None
"""
if save_offset and stream is not None:
self._pfp__offset = stream.tell()
# returns... | [
"Build",
"the",
"field",
"and",
"write",
"the",
"result",
"into",
"the",
"stream"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L759-L777 | [
"def",
"_pfp__build",
"(",
"self",
",",
"stream",
"=",
"None",
",",
"save_offset",
"=",
"False",
")",
":",
"if",
"save_offset",
"and",
"stream",
"is",
"not",
"None",
":",
"self",
".",
"_pfp__offset",
"=",
"stream",
".",
"tell",
"(",
")",
"# returns eithe... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Struct._pfp__show | Show the contents of the struct | pfp/fields.py | def _pfp__show(self, level=0, include_offset=False):
"""Show the contents of the struct
"""
res = []
res.append("{}{} {{".format(
"{:04x} ".format(self._pfp__offset) if include_offset else "",
self._pfp__show_name
))
for child in self._pfp__childre... | def _pfp__show(self, level=0, include_offset=False):
"""Show the contents of the struct
"""
res = []
res.append("{}{} {{".format(
"{:04x} ".format(self._pfp__offset) if include_offset else "",
self._pfp__show_name
))
for child in self._pfp__childre... | [
"Show",
"the",
"contents",
"of",
"the",
"struct"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L816-L832 | [
"def",
"_pfp__show",
"(",
"self",
",",
"level",
"=",
"0",
",",
"include_offset",
"=",
"False",
")",
":",
"res",
"=",
"[",
"]",
"res",
".",
"append",
"(",
"\"{}{} {{\"",
".",
"format",
"(",
"\"{:04x} \"",
".",
"format",
"(",
"self",
".",
"_pfp__offset",... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Union._pfp__add_child | Add a child to the Union field
:name: The name of the child
:child: A :class:`.Field` instance
:returns: The resulting field | pfp/fields.py | def _pfp__add_child(self, name, child, stream=None):
"""Add a child to the Union field
:name: The name of the child
:child: A :class:`.Field` instance
:returns: The resulting field
"""
res = super(Union, self)._pfp__add_child(name, child)
self._pfp__buff.seek(0, ... | def _pfp__add_child(self, name, child, stream=None):
"""Add a child to the Union field
:name: The name of the child
:child: A :class:`.Field` instance
:returns: The resulting field
"""
res = super(Union, self)._pfp__add_child(name, child)
self._pfp__buff.seek(0, ... | [
"Add",
"a",
"child",
"to",
"the",
"Union",
"field"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L851-L868 | [
"def",
"_pfp__add_child",
"(",
"self",
",",
"name",
",",
"child",
",",
"stream",
"=",
"None",
")",
":",
"res",
"=",
"super",
"(",
"Union",
",",
"self",
")",
".",
"_pfp__add_child",
"(",
"name",
",",
"child",
")",
"self",
".",
"_pfp__buff",
".",
"seek... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Union._pfp__notify_update | Handle a child with an updated value | pfp/fields.py | def _pfp__notify_update(self, child=None):
"""Handle a child with an updated value
"""
if getattr(self, "_pfp__union_update_other_children", True):
self._pfp__union_update_other_children = False
new_data = child._pfp__build()
new_stream = bitwrap.BitwrappedS... | def _pfp__notify_update(self, child=None):
"""Handle a child with an updated value
"""
if getattr(self, "_pfp__union_update_other_children", True):
self._pfp__union_update_other_children = False
new_data = child._pfp__build()
new_stream = bitwrap.BitwrappedS... | [
"Handle",
"a",
"child",
"with",
"an",
"updated",
"value"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L870-L890 | [
"def",
"_pfp__notify_update",
"(",
"self",
",",
"child",
"=",
"None",
")",
":",
"if",
"getattr",
"(",
"self",
",",
"\"_pfp__union_update_other_children\"",
",",
"True",
")",
":",
"self",
".",
"_pfp__union_update_other_children",
"=",
"False",
"new_data",
"=",
"c... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Union._pfp__parse | Parse the incoming stream
:stream: Input stream to be parsed
:returns: Number of bytes parsed | pfp/fields.py | def _pfp__parse(self, stream, save_offset=False):
"""Parse the incoming stream
:stream: Input stream to be parsed
:returns: Number of bytes parsed
"""
if save_offset:
self._pfp__offset = stream.tell()
max_res = 0
for child in self._pfp__children:
... | def _pfp__parse(self, stream, save_offset=False):
"""Parse the incoming stream
:stream: Input stream to be parsed
:returns: Number of bytes parsed
"""
if save_offset:
self._pfp__offset = stream.tell()
max_res = 0
for child in self._pfp__children:
... | [
"Parse",
"the",
"incoming",
"stream"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L892-L912 | [
"def",
"_pfp__parse",
"(",
"self",
",",
"stream",
",",
"save_offset",
"=",
"False",
")",
":",
"if",
"save_offset",
":",
"self",
".",
"_pfp__offset",
"=",
"stream",
".",
"tell",
"(",
")",
"max_res",
"=",
"0",
"for",
"child",
"in",
"self",
".",
"_pfp__ch... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Union._pfp__build | Build the union and write the result into the stream.
:stream: None
:returns: None | pfp/fields.py | def _pfp__build(self, stream=None, save_offset=False):
"""Build the union and write the result into the stream.
:stream: None
:returns: None
"""
max_size = -1
if stream is None:
core_stream = six.BytesIO()
new_stream = bitwrap.BitwrappedStream(cor... | def _pfp__build(self, stream=None, save_offset=False):
"""Build the union and write the result into the stream.
:stream: None
:returns: None
"""
max_size = -1
if stream is None:
core_stream = six.BytesIO()
new_stream = bitwrap.BitwrappedStream(cor... | [
"Build",
"the",
"union",
"and",
"write",
"the",
"result",
"into",
"the",
"stream",
"."
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L914-L941 | [
"def",
"_pfp__build",
"(",
"self",
",",
"stream",
"=",
"None",
",",
"save_offset",
"=",
"False",
")",
":",
"max_size",
"=",
"-",
"1",
"if",
"stream",
"is",
"None",
":",
"core_stream",
"=",
"six",
".",
"BytesIO",
"(",
")",
"new_stream",
"=",
"bitwrap",
... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | NumberBase._pfp__parse | Parse the IO stream for this numeric field
:stream: An IO stream that can be read from
:returns: The number of bytes parsed | pfp/fields.py | def _pfp__parse(self, stream, save_offset=False):
"""Parse the IO stream for this numeric field
:stream: An IO stream that can be read from
:returns: The number of bytes parsed
"""
if save_offset:
self._pfp__offset = stream.tell()
if self.bitsize is None:
... | def _pfp__parse(self, stream, save_offset=False):
"""Parse the IO stream for this numeric field
:stream: An IO stream that can be read from
:returns: The number of bytes parsed
"""
if save_offset:
self._pfp__offset = stream.tell()
if self.bitsize is None:
... | [
"Parse",
"the",
"IO",
"stream",
"for",
"this",
"numeric",
"field"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L1032-L1068 | [
"def",
"_pfp__parse",
"(",
"self",
",",
"stream",
",",
"save_offset",
"=",
"False",
")",
":",
"if",
"save_offset",
":",
"self",
".",
"_pfp__offset",
"=",
"stream",
".",
"tell",
"(",
")",
"if",
"self",
".",
"bitsize",
"is",
"None",
":",
"raw_data",
"=",... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | NumberBase._pfp__build | Build the field and write the result into the stream
:stream: An IO stream that can be written to
:returns: None | pfp/fields.py | def _pfp__build(self, stream=None, save_offset=False):
"""Build the field and write the result into the stream
:stream: An IO stream that can be written to
:returns: None
"""
if stream is not None and save_offset:
self._pfp__offset = stream.tell()
if self.b... | def _pfp__build(self, stream=None, save_offset=False):
"""Build the field and write the result into the stream
:stream: An IO stream that can be written to
:returns: None
"""
if stream is not None and save_offset:
self._pfp__offset = stream.tell()
if self.b... | [
"Build",
"the",
"field",
"and",
"write",
"the",
"result",
"into",
"the",
"stream"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L1070-L1107 | [
"def",
"_pfp__build",
"(",
"self",
",",
"stream",
"=",
"None",
",",
"save_offset",
"=",
"False",
")",
":",
"if",
"stream",
"is",
"not",
"None",
"and",
"save_offset",
":",
"self",
".",
"_pfp__offset",
"=",
"stream",
".",
"tell",
"(",
")",
"if",
"self",
... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | NumberBase._dom_class | Return the dominating numeric class between the two
:obj1: TODO
:obj2: TODO
:returns: TODO | pfp/fields.py | def _dom_class(self, obj1, obj2):
"""Return the dominating numeric class between the two
:obj1: TODO
:obj2: TODO
:returns: TODO
"""
if isinstance(obj1, Double) or isinstance(obj2, Double):
return Double
if isinstance(obj1, Float) or isinstance(obj2, ... | def _dom_class(self, obj1, obj2):
"""Return the dominating numeric class between the two
:obj1: TODO
:obj2: TODO
:returns: TODO
"""
if isinstance(obj1, Double) or isinstance(obj2, Double):
return Double
if isinstance(obj1, Float) or isinstance(obj2, ... | [
"Return",
"the",
"dominating",
"numeric",
"class",
"between",
"the",
"two"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L1109-L1120 | [
"def",
"_dom_class",
"(",
"self",
",",
"obj1",
",",
"obj2",
")",
":",
"if",
"isinstance",
"(",
"obj1",
",",
"Double",
")",
"or",
"isinstance",
"(",
"obj2",
",",
"Double",
")",
":",
"return",
"Double",
"if",
"isinstance",
"(",
"obj1",
",",
"Float",
")... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | IntBase._pfp__set_value | Set the value, potentially converting an unsigned
value to a signed one (and visa versa) | pfp/fields.py | def _pfp__set_value(self, new_val):
"""Set the value, potentially converting an unsigned
value to a signed one (and visa versa)"""
if self._pfp__frozen:
raise errors.UnmodifiableConst()
if isinstance(new_val, IntBase):
# will automatically convert correctly betwe... | def _pfp__set_value(self, new_val):
"""Set the value, potentially converting an unsigned
value to a signed one (and visa versa)"""
if self._pfp__frozen:
raise errors.UnmodifiableConst()
if isinstance(new_val, IntBase):
# will automatically convert correctly betwe... | [
"Set",
"the",
"value",
"potentially",
"converting",
"an",
"unsigned",
"value",
"to",
"a",
"signed",
"one",
"(",
"and",
"visa",
"versa",
")"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L1247-L1289 | [
"def",
"_pfp__set_value",
"(",
"self",
",",
"new_val",
")",
":",
"if",
"self",
".",
"_pfp__frozen",
":",
"raise",
"errors",
".",
"UnmodifiableConst",
"(",
")",
"if",
"isinstance",
"(",
"new_val",
",",
"IntBase",
")",
":",
"# will automatically convert correctly ... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Enum._pfp__parse | Parse the IO stream for this enum
:stream: An IO stream that can be read from
:returns: The number of bytes parsed | pfp/fields.py | def _pfp__parse(self, stream, save_offset=False):
"""Parse the IO stream for this enum
:stream: An IO stream that can be read from
:returns: The number of bytes parsed
"""
res = super(Enum, self)._pfp__parse(stream, save_offset)
if self._pfp__value in self.enum_vals:
... | def _pfp__parse(self, stream, save_offset=False):
"""Parse the IO stream for this enum
:stream: An IO stream that can be read from
:returns: The number of bytes parsed
"""
res = super(Enum, self)._pfp__parse(stream, save_offset)
if self._pfp__value in self.enum_vals:
... | [
"Parse",
"the",
"IO",
"stream",
"for",
"this",
"enum"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L1410-L1423 | [
"def",
"_pfp__parse",
"(",
"self",
",",
"stream",
",",
"save_offset",
"=",
"False",
")",
":",
"res",
"=",
"super",
"(",
"Enum",
",",
"self",
")",
".",
"_pfp__parse",
"(",
"stream",
",",
"save_offset",
")",
"if",
"self",
".",
"_pfp__value",
"in",
"self"... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Array._pfp__snapshot | Save off the current value of the field | pfp/fields.py | def _pfp__snapshot(self, recurse=True):
"""Save off the current value of the field
"""
super(Array, self)._pfp__snapshot(recurse=recurse)
self.snapshot_raw_data = self.raw_data
if recurse:
for item in self.items:
item._pfp__snapshot(recurse=recurse) | def _pfp__snapshot(self, recurse=True):
"""Save off the current value of the field
"""
super(Array, self)._pfp__snapshot(recurse=recurse)
self.snapshot_raw_data = self.raw_data
if recurse:
for item in self.items:
item._pfp__snapshot(recurse=recurse) | [
"Save",
"off",
"the",
"current",
"value",
"of",
"the",
"field"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L1475-L1483 | [
"def",
"_pfp__snapshot",
"(",
"self",
",",
"recurse",
"=",
"True",
")",
":",
"super",
"(",
"Array",
",",
"self",
")",
".",
"_pfp__snapshot",
"(",
"recurse",
"=",
"recurse",
")",
"self",
".",
"snapshot_raw_data",
"=",
"self",
".",
"raw_data",
"if",
"recur... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | String._pfp__set_value | Set the value of the String, taking into account
escaping and such as well | pfp/fields.py | def _pfp__set_value(self, new_val):
"""Set the value of the String, taking into account
escaping and such as well
"""
if not isinstance(new_val, Field):
new_val = utils.binary(utils.string_escape(new_val))
super(String, self)._pfp__set_value(new_val) | def _pfp__set_value(self, new_val):
"""Set the value of the String, taking into account
escaping and such as well
"""
if not isinstance(new_val, Field):
new_val = utils.binary(utils.string_escape(new_val))
super(String, self)._pfp__set_value(new_val) | [
"Set",
"the",
"value",
"of",
"the",
"String",
"taking",
"into",
"account",
"escaping",
"and",
"such",
"as",
"well"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L1743-L1749 | [
"def",
"_pfp__set_value",
"(",
"self",
",",
"new_val",
")",
":",
"if",
"not",
"isinstance",
"(",
"new_val",
",",
"Field",
")",
":",
"new_val",
"=",
"utils",
".",
"binary",
"(",
"utils",
".",
"string_escape",
"(",
"new_val",
")",
")",
"super",
"(",
"Str... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | String._pfp__parse | Read from the stream until the string is null-terminated
:stream: The input stream
:returns: None | pfp/fields.py | def _pfp__parse(self, stream, save_offset=False):
"""Read from the stream until the string is null-terminated
:stream: The input stream
:returns: None
"""
if save_offset:
self._pfp__offset = stream.tell()
res = utils.binary("")
while True:
... | def _pfp__parse(self, stream, save_offset=False):
"""Read from the stream until the string is null-terminated
:stream: The input stream
:returns: None
"""
if save_offset:
self._pfp__offset = stream.tell()
res = utils.binary("")
while True:
... | [
"Read",
"from",
"the",
"stream",
"until",
"the",
"string",
"is",
"null",
"-",
"terminated"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L1751-L1771 | [
"def",
"_pfp__parse",
"(",
"self",
",",
"stream",
",",
"save_offset",
"=",
"False",
")",
":",
"if",
"save_offset",
":",
"self",
".",
"_pfp__offset",
"=",
"stream",
".",
"tell",
"(",
")",
"res",
"=",
"utils",
".",
"binary",
"(",
"\"\"",
")",
"while",
... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | String._pfp__build | Build the String field
:stream: TODO
:returns: TODO | pfp/fields.py | def _pfp__build(self, stream=None, save_offset=False):
"""Build the String field
:stream: TODO
:returns: TODO
"""
if stream is not None and save_offset:
self._pfp__offset = stream.tell()
data = self._pfp__value + utils.binary("\x00")
if stream is No... | def _pfp__build(self, stream=None, save_offset=False):
"""Build the String field
:stream: TODO
:returns: TODO
"""
if stream is not None and save_offset:
self._pfp__offset = stream.tell()
data = self._pfp__value + utils.binary("\x00")
if stream is No... | [
"Build",
"the",
"String",
"field"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fields.py#L1773-L1788 | [
"def",
"_pfp__build",
"(",
"self",
",",
"stream",
"=",
"None",
",",
"save_offset",
"=",
"False",
")",
":",
"if",
"stream",
"is",
"not",
"None",
"and",
"save_offset",
":",
"self",
".",
"_pfp__offset",
"=",
"stream",
".",
"tell",
"(",
")",
"data",
"=",
... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Printf | Prints format string to stdout
:params: TODO
:returns: TODO | pfp/native/compat_interface.py | def Printf(params, ctxt, scope, stream, coord, interp):
"""Prints format string to stdout
:params: TODO
:returns: TODO
"""
if len(params) == 1:
if interp._printf:
sys.stdout.write(PYSTR(params[0]))
return len(PYSTR(params[0]))
parts = []
for part in params[1:]:... | def Printf(params, ctxt, scope, stream, coord, interp):
"""Prints format string to stdout
:params: TODO
:returns: TODO
"""
if len(params) == 1:
if interp._printf:
sys.stdout.write(PYSTR(params[0]))
return len(PYSTR(params[0]))
parts = []
for part in params[1:]:... | [
"Prints",
"format",
"string",
"to",
"stdout"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/native/compat_interface.py#L542-L567 | [
"def",
"Printf",
"(",
"params",
",",
"ctxt",
",",
"scope",
",",
"stream",
",",
"coord",
",",
"interp",
")",
":",
"if",
"len",
"(",
"params",
")",
"==",
"1",
":",
"if",
"interp",
".",
"_printf",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"PYSTR... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | mutate | Mutate the provided field (probably a Dom or struct instance) using the
strategy specified with ``strat_name_or_class``, yielding ``num`` mutations
that affect up to ``at_once`` fields at once.
This function will yield back the field after each mutation, optionally
also yielding a ``set`` of fields tha... | pfp/fuzz/__init__.py | def mutate(field, strat_name_or_cls, num=100, at_once=1, yield_changed=False):
"""Mutate the provided field (probably a Dom or struct instance) using the
strategy specified with ``strat_name_or_class``, yielding ``num`` mutations
that affect up to ``at_once`` fields at once.
This function will yield ba... | def mutate(field, strat_name_or_cls, num=100, at_once=1, yield_changed=False):
"""Mutate the provided field (probably a Dom or struct instance) using the
strategy specified with ``strat_name_or_class``, yielding ``num`` mutations
that affect up to ``at_once`` fields at once.
This function will yield ba... | [
"Mutate",
"the",
"provided",
"field",
"(",
"probably",
"a",
"Dom",
"or",
"struct",
"instance",
")",
"using",
"the",
"strategy",
"specified",
"with",
"strat_name_or_class",
"yielding",
"num",
"mutations",
"that",
"affect",
"up",
"to",
"at_once",
"fields",
"at",
... | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fuzz/__init__.py#L39-L103 | [
"def",
"mutate",
"(",
"field",
",",
"strat_name_or_cls",
",",
"num",
"=",
"100",
",",
"at_once",
"=",
"1",
",",
"yield_changed",
"=",
"False",
")",
":",
"import",
"pfp",
".",
"fuzz",
".",
"rand",
"as",
"rand",
"init",
"(",
")",
"strat",
"=",
"get_str... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | get_strategy | Return the strategy identified by its name. If ``name_or_class`` is a class,
it will be simply returned. | pfp/fuzz/strats.py | def get_strategy(name_or_cls):
"""Return the strategy identified by its name. If ``name_or_class`` is a class,
it will be simply returned.
"""
if isinstance(name_or_cls, six.string_types):
if name_or_cls not in STRATS:
raise MutationError("strat is not defined")
return STRATS... | def get_strategy(name_or_cls):
"""Return the strategy identified by its name. If ``name_or_class`` is a class,
it will be simply returned.
"""
if isinstance(name_or_cls, six.string_types):
if name_or_cls not in STRATS:
raise MutationError("strat is not defined")
return STRATS... | [
"Return",
"the",
"strategy",
"identified",
"by",
"its",
"name",
".",
"If",
"name_or_class",
"is",
"a",
"class",
"it",
"will",
"be",
"simply",
"returned",
"."
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fuzz/strats.py#L29-L38 | [
"def",
"get_strategy",
"(",
"name_or_cls",
")",
":",
"if",
"isinstance",
"(",
"name_or_cls",
",",
"six",
".",
"string_types",
")",
":",
"if",
"name_or_cls",
"not",
"in",
"STRATS",
":",
"raise",
"MutationError",
"(",
"\"strat is not defined\"",
")",
"return",
"... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | FieldStrat.mutate | Mutate the given field, modifying it directly. This is not
intended to preserve the value of the field.
:field: The pfp.fields.Field instance that will receive the new value | pfp/fuzz/strats.py | def mutate(self, field):
"""Mutate the given field, modifying it directly. This is not
intended to preserve the value of the field.
:field: The pfp.fields.Field instance that will receive the new value
"""
new_val = self.next_val(field)
field._pfp__set_value(new_val)
... | def mutate(self, field):
"""Mutate the given field, modifying it directly. This is not
intended to preserve the value of the field.
:field: The pfp.fields.Field instance that will receive the new value
"""
new_val = self.next_val(field)
field._pfp__set_value(new_val)
... | [
"Mutate",
"the",
"given",
"field",
"modifying",
"it",
"directly",
".",
"This",
"is",
"not",
"intended",
"to",
"preserve",
"the",
"value",
"of",
"the",
"field",
"."
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fuzz/strats.py#L194-L202 | [
"def",
"mutate",
"(",
"self",
",",
"field",
")",
":",
"new_val",
"=",
"self",
".",
"next_val",
"(",
"field",
")",
"field",
".",
"_pfp__set_value",
"(",
"new_val",
")",
"return",
"field"
] | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | FieldStrat.next_val | Return a new value to mutate a field with. Do not modify the field directly
in this function. Override the ``mutate()`` function if that is needed (the field is
only passed into this function as a reference).
:field: The pfp.fields.Field instance that will receive the new value. Passed in for r... | pfp/fuzz/strats.py | def next_val(self, field):
"""Return a new value to mutate a field with. Do not modify the field directly
in this function. Override the ``mutate()`` function if that is needed (the field is
only passed into this function as a reference).
:field: The pfp.fields.Field instance that will ... | def next_val(self, field):
"""Return a new value to mutate a field with. Do not modify the field directly
in this function. Override the ``mutate()`` function if that is needed (the field is
only passed into this function as a reference).
:field: The pfp.fields.Field instance that will ... | [
"Return",
"a",
"new",
"value",
"to",
"mutate",
"a",
"field",
"with",
".",
"Do",
"not",
"modify",
"the",
"field",
"directly",
"in",
"this",
"function",
".",
"Override",
"the",
"mutate",
"()",
"function",
"if",
"that",
"is",
"needed",
"(",
"the",
"field",
... | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/fuzz/strats.py#L204-L232 | [
"def",
"next_val",
"(",
"self",
",",
"field",
")",
":",
"import",
"pfp",
".",
"fuzz",
".",
"rand",
"as",
"rand",
"if",
"self",
".",
"choices",
"is",
"not",
"None",
":",
"choices",
"=",
"self",
".",
"_resolve_member_val",
"(",
"self",
".",
"choices",
... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | generate_subid | generate a new user in the database, still session based so we
create a new identifier. | expfactory/database/relational.py | def generate_subid(self, token=None, return_user=False):
'''generate a new user in the database, still session based so we
create a new identifier.
'''
from expfactory.database.models import Participant
if not token:
p = Participant()
else:
p = Participant(token=token)
... | def generate_subid(self, token=None, return_user=False):
'''generate a new user in the database, still session based so we
create a new identifier.
'''
from expfactory.database.models import Participant
if not token:
p = Participant()
else:
p = Participant(token=token)
... | [
"generate",
"a",
"new",
"user",
"in",
"the",
"database",
"still",
"session",
"based",
"so",
"we",
"create",
"a",
"new",
"identifier",
"."
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L65-L78 | [
"def",
"generate_subid",
"(",
"self",
",",
"token",
"=",
"None",
",",
"return_user",
"=",
"False",
")",
":",
"from",
"expfactory",
".",
"database",
".",
"models",
"import",
"Participant",
"if",
"not",
"token",
":",
"p",
"=",
"Participant",
"(",
")",
"els... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | print_user | print a relational database user | expfactory/database/relational.py | def print_user(self, user):
'''print a relational database user
'''
status = "active"
token = user.token
if token in ['finished', 'revoked']:
status = token
if token is None:
token = ''
subid = "%s\t%s[%s]" %(user.id, token, status)
print(subid)
return subid | def print_user(self, user):
'''print a relational database user
'''
status = "active"
token = user.token
if token in ['finished', 'revoked']:
status = token
if token is None:
token = ''
subid = "%s\t%s[%s]" %(user.id, token, status)
print(subid)
return subid | [
"print",
"a",
"relational",
"database",
"user"
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L81-L95 | [
"def",
"print_user",
"(",
"self",
",",
"user",
")",
":",
"status",
"=",
"\"active\"",
"token",
"=",
"user",
".",
"token",
"if",
"token",
"in",
"[",
"'finished'",
",",
"'revoked'",
"]",
":",
"status",
"=",
"token",
"if",
"token",
"is",
"None",
":",
"t... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | list_users | list users, each having a model in the database. A headless experiment
will use protected tokens, and interactive will be based on auto-
incremented ids. | expfactory/database/relational.py | def list_users(self, user=None):
'''list users, each having a model in the database. A headless experiment
will use protected tokens, and interactive will be based on auto-
incremented ids.
'''
from expfactory.database.models import Participant
participants = Participant.query.all()
u... | def list_users(self, user=None):
'''list users, each having a model in the database. A headless experiment
will use protected tokens, and interactive will be based on auto-
incremented ids.
'''
from expfactory.database.models import Participant
participants = Participant.query.all()
u... | [
"list",
"users",
"each",
"having",
"a",
"model",
"in",
"the",
"database",
".",
"A",
"headless",
"experiment",
"will",
"use",
"protected",
"tokens",
"and",
"interactive",
"will",
"be",
"based",
"on",
"auto",
"-",
"incremented",
"ids",
"."
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L98-L108 | [
"def",
"list_users",
"(",
"self",
",",
"user",
"=",
"None",
")",
":",
"from",
"expfactory",
".",
"database",
".",
"models",
"import",
"Participant",
"participants",
"=",
"Participant",
".",
"query",
".",
"all",
"(",
")",
"users",
"=",
"[",
"]",
"for",
... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | generate_user | generate a new user in the database, still session based so we
create a new identifier. This function is called from the users new
entrypoint, and it assumes we want a user generated with a token. | expfactory/database/relational.py | def generate_user(self):
'''generate a new user in the database, still session based so we
create a new identifier. This function is called from the users new
entrypoint, and it assumes we want a user generated with a token.
'''
token = str(uuid.uuid4())
return self.generate_subid(token=t... | def generate_user(self):
'''generate a new user in the database, still session based so we
create a new identifier. This function is called from the users new
entrypoint, and it assumes we want a user generated with a token.
'''
token = str(uuid.uuid4())
return self.generate_subid(token=t... | [
"generate",
"a",
"new",
"user",
"in",
"the",
"database",
"still",
"session",
"based",
"so",
"we",
"create",
"a",
"new",
"identifier",
".",
"This",
"function",
"is",
"called",
"from",
"the",
"users",
"new",
"entrypoint",
"and",
"it",
"assumes",
"we",
"want"... | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L113-L119 | [
"def",
"generate_user",
"(",
"self",
")",
":",
"token",
"=",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
"return",
"self",
".",
"generate_subid",
"(",
"token",
"=",
"token",
",",
"return_user",
"=",
"True",
")"
] | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | finish_user | finish user will remove a user's token, making the user entry not
accesible if running in headless model | expfactory/database/relational.py | def finish_user(self, subid):
'''finish user will remove a user's token, making the user entry not
accesible if running in headless model'''
p = self.revoke_token(subid)
p.token = "finished"
self.session.commit()
return p | def finish_user(self, subid):
'''finish user will remove a user's token, making the user entry not
accesible if running in headless model'''
p = self.revoke_token(subid)
p.token = "finished"
self.session.commit()
return p | [
"finish",
"user",
"will",
"remove",
"a",
"user",
"s",
"token",
"making",
"the",
"user",
"entry",
"not",
"accesible",
"if",
"running",
"in",
"headless",
"model"
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L122-L129 | [
"def",
"finish_user",
"(",
"self",
",",
"subid",
")",
":",
"p",
"=",
"self",
".",
"revoke_token",
"(",
"subid",
")",
"p",
".",
"token",
"=",
"\"finished\"",
"self",
".",
"session",
".",
"commit",
"(",
")",
"return",
"p"
] | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | restart_user | restart a user, which means revoking and issuing a new token. | expfactory/database/relational.py | def restart_user(self, subid):
'''restart a user, which means revoking and issuing a new token.'''
p = self.revoke_token(subid)
p = self.refresh_token(subid)
return p | def restart_user(self, subid):
'''restart a user, which means revoking and issuing a new token.'''
p = self.revoke_token(subid)
p = self.refresh_token(subid)
return p | [
"restart",
"a",
"user",
"which",
"means",
"revoking",
"and",
"issuing",
"a",
"new",
"token",
"."
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L132-L136 | [
"def",
"restart_user",
"(",
"self",
",",
"subid",
")",
":",
"p",
"=",
"self",
".",
"revoke_token",
"(",
"subid",
")",
"p",
"=",
"self",
".",
"refresh_token",
"(",
"subid",
")",
"return",
"p"
] | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | validate_token | retrieve a subject based on a token. Valid means we return a participant
invalid means we return None | expfactory/database/relational.py | def validate_token(self, token):
'''retrieve a subject based on a token. Valid means we return a participant
invalid means we return None
'''
from expfactory.database.models import Participant
p = Participant.query.filter(Participant.token == token).first()
if p is not None:
if p.toke... | def validate_token(self, token):
'''retrieve a subject based on a token. Valid means we return a participant
invalid means we return None
'''
from expfactory.database.models import Participant
p = Participant.query.filter(Participant.token == token).first()
if p is not None:
if p.toke... | [
"retrieve",
"a",
"subject",
"based",
"on",
"a",
"token",
".",
"Valid",
"means",
"we",
"return",
"a",
"participant",
"invalid",
"means",
"we",
"return",
"None"
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L142-L153 | [
"def",
"validate_token",
"(",
"self",
",",
"token",
")",
":",
"from",
"expfactory",
".",
"database",
".",
"models",
"import",
"Participant",
"p",
"=",
"Participant",
".",
"query",
".",
"filter",
"(",
"Participant",
".",
"token",
"==",
"token",
")",
".",
... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | revoke_token | revoke a token by removing it. Is done at finish, and also available
as a command line option | expfactory/database/relational.py | def revoke_token(self, subid):
'''revoke a token by removing it. Is done at finish, and also available
as a command line option'''
from expfactory.database.models import Participant
p = Participant.query.filter(Participant.id == subid).first()
if p is not None:
p.token = 'revoked'
self.s... | def revoke_token(self, subid):
'''revoke a token by removing it. Is done at finish, and also available
as a command line option'''
from expfactory.database.models import Participant
p = Participant.query.filter(Participant.id == subid).first()
if p is not None:
p.token = 'revoked'
self.s... | [
"revoke",
"a",
"token",
"by",
"removing",
"it",
".",
"Is",
"done",
"at",
"finish",
"and",
"also",
"available",
"as",
"a",
"command",
"line",
"option"
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L156-L164 | [
"def",
"revoke_token",
"(",
"self",
",",
"subid",
")",
":",
"from",
"expfactory",
".",
"database",
".",
"models",
"import",
"Participant",
"p",
"=",
"Participant",
".",
"query",
".",
"filter",
"(",
"Participant",
".",
"id",
"==",
"subid",
")",
".",
"firs... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | refresh_token | refresh or generate a new token for a user | expfactory/database/relational.py | def refresh_token(self, subid):
'''refresh or generate a new token for a user'''
from expfactory.database.models import Participant
p = Participant.query.filter(Participant.id == subid).first()
if p is not None:
p.token = str(uuid.uuid4())
self.session.commit()
return p | def refresh_token(self, subid):
'''refresh or generate a new token for a user'''
from expfactory.database.models import Participant
p = Participant.query.filter(Participant.id == subid).first()
if p is not None:
p.token = str(uuid.uuid4())
self.session.commit()
return p | [
"refresh",
"or",
"generate",
"a",
"new",
"token",
"for",
"a",
"user"
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L167-L174 | [
"def",
"refresh_token",
"(",
"self",
",",
"subid",
")",
":",
"from",
"expfactory",
".",
"database",
".",
"models",
"import",
"Participant",
"p",
"=",
"Participant",
".",
"query",
".",
"filter",
"(",
"Participant",
".",
"id",
"==",
"subid",
")",
".",
"fir... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | save_data | save data will obtain the current subid from the session, and save it
depending on the database type. Currently we just support flat files | expfactory/database/relational.py | def save_data(self,session, exp_id, content):
'''save data will obtain the current subid from the session, and save it
depending on the database type. Currently we just support flat files'''
from expfactory.database.models import (
Participant,
Result
)
subid = session.get('subid'... | def save_data(self,session, exp_id, content):
'''save data will obtain the current subid from the session, and save it
depending on the database type. Currently we just support flat files'''
from expfactory.database.models import (
Participant,
Result
)
subid = session.get('subid'... | [
"save",
"data",
"will",
"obtain",
"the",
"current",
"subid",
"from",
"the",
"session",
"and",
"save",
"it",
"depending",
"on",
"the",
"database",
"type",
".",
"Currently",
"we",
"just",
"support",
"flat",
"files"
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L177-L213 | [
"def",
"save_data",
"(",
"self",
",",
"session",
",",
"exp_id",
",",
"content",
")",
":",
"from",
"expfactory",
".",
"database",
".",
"models",
"import",
"(",
"Participant",
",",
"Result",
")",
"subid",
"=",
"session",
".",
"get",
"(",
"'subid'",
")",
... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | init_db | initialize the database, with the default database path or custom with
a format corresponding to the database type:
Examples:
sqlite:////scif/data/expfactory.db | expfactory/database/relational.py | def init_db(self):
'''initialize the database, with the default database path or custom with
a format corresponding to the database type:
Examples:
sqlite:////scif/data/expfactory.db
'''
# The user can provide a custom string
if self.database is None:
self.logger.error("Y... | def init_db(self):
'''initialize the database, with the default database path or custom with
a format corresponding to the database type:
Examples:
sqlite:////scif/data/expfactory.db
'''
# The user can provide a custom string
if self.database is None:
self.logger.error("Y... | [
"initialize",
"the",
"database",
"with",
"the",
"default",
"database",
"path",
"or",
"custom",
"with",
"a",
"format",
"corresponding",
"to",
"the",
"database",
"type",
":"
] | expfactory/expfactory | python | https://github.com/expfactory/expfactory/blob/27ce6cc93e17231df8a8024f18e631336afd3501/expfactory/database/relational.py#L219-L246 | [
"def",
"init_db",
"(",
"self",
")",
":",
"# The user can provide a custom string",
"if",
"self",
".",
"database",
"is",
"None",
":",
"self",
".",
"logger",
".",
"error",
"(",
"\"You must provide a database url, exiting.\"",
")",
"sys",
".",
"exit",
"(",
"1",
")"... | 27ce6cc93e17231df8a8024f18e631336afd3501 |
train | LazyField | Super non-standard stuff here. Dynamically changing the base
class using the scope and the lazy name when the class is
instantiated. This works as long as the original base class is
not directly inheriting from object (which we're not, since
our original base class is fields.Field). | pfp/interp.py | def LazyField(lookup_name, scope):
"""Super non-standard stuff here. Dynamically changing the base
class using the scope and the lazy name when the class is
instantiated. This works as long as the original base class is
not directly inheriting from object (which we're not, since
our original base cl... | def LazyField(lookup_name, scope):
"""Super non-standard stuff here. Dynamically changing the base
class using the scope and the lazy name when the class is
instantiated. This works as long as the original base class is
not directly inheriting from object (which we're not, since
our original base cl... | [
"Super",
"non",
"-",
"standard",
"stuff",
"here",
".",
"Dynamically",
"changing",
"the",
"base",
"class",
"using",
"the",
"scope",
"and",
"the",
"lazy",
"name",
"when",
"the",
"class",
"is",
"instantiated",
".",
"This",
"works",
"as",
"long",
"as",
"the",
... | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L113-L130 | [
"def",
"LazyField",
"(",
"lookup_name",
",",
"scope",
")",
":",
"def",
"__init__",
"(",
"self",
",",
"stream",
"=",
"None",
")",
":",
"base_cls",
"=",
"self",
".",
"_pfp__scope",
".",
"get_id",
"(",
"self",
".",
"_pfp__lazy_name",
")",
"self",
".",
"__... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | PfpTypes._wrap_type_instantiation | Wrap the creation of the type so that we can provide
a null-stream to initialize it | pfp/interp.py | def _wrap_type_instantiation(self, type_cls):
"""Wrap the creation of the type so that we can provide
a null-stream to initialize it"""
def wrapper(*args, **kwargs):
# use args for struct arguments??
return type_cls(stream=self._null_stream)
return wrapper | def _wrap_type_instantiation(self, type_cls):
"""Wrap the creation of the type so that we can provide
a null-stream to initialize it"""
def wrapper(*args, **kwargs):
# use args for struct arguments??
return type_cls(stream=self._null_stream)
return wrapper | [
"Wrap",
"the",
"creation",
"of",
"the",
"type",
"so",
"that",
"we",
"can",
"provide",
"a",
"null",
"-",
"stream",
"to",
"initialize",
"it"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L241-L247 | [
"def",
"_wrap_type_instantiation",
"(",
"self",
",",
"type_cls",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# use args for struct arguments??",
"return",
"type_cls",
"(",
"stream",
"=",
"self",
".",
"_null_stream",
")",
... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Scope.level | Return the current scope level | pfp/interp.py | def level(self):
"""Return the current scope level
"""
res = len(self._scope_stack)
if self._parent is not None:
res += self._parent.level()
return res | def level(self):
"""Return the current scope level
"""
res = len(self._scope_stack)
if self._parent is not None:
res += self._parent.level()
return res | [
"Return",
"the",
"current",
"scope",
"level"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L273-L279 | [
"def",
"level",
"(",
"self",
")",
":",
"res",
"=",
"len",
"(",
"self",
".",
"_scope_stack",
")",
"if",
"self",
".",
"_parent",
"is",
"not",
"None",
":",
"res",
"+=",
"self",
".",
"_parent",
".",
"level",
"(",
")",
"return",
"res"
] | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Scope.push | Create a new scope
:returns: TODO | pfp/interp.py | def push(self, new_scope=None):
"""Create a new scope
:returns: TODO
"""
if new_scope is None:
new_scope = {
"types": {},
"vars": {}
}
self._curr_scope = new_scope
self._dlog("pushing new scope, scope level = {}".fo... | def push(self, new_scope=None):
"""Create a new scope
:returns: TODO
"""
if new_scope is None:
new_scope = {
"types": {},
"vars": {}
}
self._curr_scope = new_scope
self._dlog("pushing new scope, scope level = {}".fo... | [
"Create",
"a",
"new",
"scope",
":",
"returns",
":",
"TODO"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L281-L293 | [
"def",
"push",
"(",
"self",
",",
"new_scope",
"=",
"None",
")",
":",
"if",
"new_scope",
"is",
"None",
":",
"new_scope",
"=",
"{",
"\"types\"",
":",
"{",
"}",
",",
"\"vars\"",
":",
"{",
"}",
"}",
"self",
".",
"_curr_scope",
"=",
"new_scope",
"self",
... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Scope.clone | Return a new Scope object that has the curr_scope
pinned at the current one
:returns: A new scope object | pfp/interp.py | def clone(self):
"""Return a new Scope object that has the curr_scope
pinned at the current one
:returns: A new scope object
"""
self._dlog("cloning the stack")
# TODO is this really necessary to create a brand new one?
# I think it is... need to think about it mo... | def clone(self):
"""Return a new Scope object that has the curr_scope
pinned at the current one
:returns: A new scope object
"""
self._dlog("cloning the stack")
# TODO is this really necessary to create a brand new one?
# I think it is... need to think about it mo... | [
"Return",
"a",
"new",
"Scope",
"object",
"that",
"has",
"the",
"curr_scope",
"pinned",
"at",
"the",
"current",
"one",
":",
"returns",
":",
"A",
"new",
"scope",
"object"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L295-L309 | [
"def",
"clone",
"(",
"self",
")",
":",
"self",
".",
"_dlog",
"(",
"\"cloning the stack\"",
")",
"# TODO is this really necessary to create a brand new one?",
"# I think it is... need to think about it more.",
"# or... are we going to need ref counters and a global",
"# scope object tha... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Scope.pop | Leave the current scope
:returns: TODO | pfp/interp.py | def pop(self):
"""Leave the current scope
:returns: TODO
"""
res = self._scope_stack.pop()
self._dlog("popping scope, scope level = {}".format(self.level()))
self._curr_scope = self._scope_stack[-1]
return res | def pop(self):
"""Leave the current scope
:returns: TODO
"""
res = self._scope_stack.pop()
self._dlog("popping scope, scope level = {}".format(self.level()))
self._curr_scope = self._scope_stack[-1]
return res | [
"Leave",
"the",
"current",
"scope",
":",
"returns",
":",
"TODO"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L311-L319 | [
"def",
"pop",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"_scope_stack",
".",
"pop",
"(",
")",
"self",
".",
"_dlog",
"(",
"\"popping scope, scope level = {}\"",
".",
"format",
"(",
"self",
".",
"level",
"(",
")",
")",
")",
"self",
".",
"_curr_scop... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Scope.add_var | Add a var to the current scope (vars are fields that
parse the input stream)
:field_name: TODO
:field: TODO
:returns: TODO | pfp/interp.py | def add_var(self, field_name, field, root=False):
"""Add a var to the current scope (vars are fields that
parse the input stream)
:field_name: TODO
:field: TODO
:returns: TODO
"""
self._dlog("adding var '{}' (root={})".format(field_name, root))
# do bot... | def add_var(self, field_name, field, root=False):
"""Add a var to the current scope (vars are fields that
parse the input stream)
:field_name: TODO
:field: TODO
:returns: TODO
"""
self._dlog("adding var '{}' (root={})".format(field_name, root))
# do bot... | [
"Add",
"a",
"var",
"to",
"the",
"current",
"scope",
"(",
"vars",
"are",
"fields",
"that",
"parse",
"the",
"input",
"stream",
")"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L321-L337 | [
"def",
"add_var",
"(",
"self",
",",
"field_name",
",",
"field",
",",
"root",
"=",
"False",
")",
":",
"self",
".",
"_dlog",
"(",
"\"adding var '{}' (root={})\"",
".",
"format",
"(",
"field_name",
",",
"root",
")",
")",
"# do both so it's not clobbered by intermed... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Scope.get_var | Return the first var of name ``name`` in the current
scope stack (remember, vars are the ones that parse the
input stream)
:name: The name of the id
:recurse: Whether parent scopes should also be searched (defaults to True)
:returns: TODO | pfp/interp.py | def get_var(self, name, recurse=True):
"""Return the first var of name ``name`` in the current
scope stack (remember, vars are the ones that parse the
input stream)
:name: The name of the id
:recurse: Whether parent scopes should also be searched (defaults to True)
:retu... | def get_var(self, name, recurse=True):
"""Return the first var of name ``name`` in the current
scope stack (remember, vars are the ones that parse the
input stream)
:name: The name of the id
:recurse: Whether parent scopes should also be searched (defaults to True)
:retu... | [
"Return",
"the",
"first",
"var",
"of",
"name",
"name",
"in",
"the",
"current",
"scope",
"stack",
"(",
"remember",
"vars",
"are",
"the",
"ones",
"that",
"parse",
"the",
"input",
"stream",
")"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L340-L351 | [
"def",
"get_var",
"(",
"self",
",",
"name",
",",
"recurse",
"=",
"True",
")",
":",
"self",
".",
"_dlog",
"(",
"\"getting var '{}'\"",
".",
"format",
"(",
"name",
")",
")",
"return",
"self",
".",
"_search",
"(",
"\"vars\"",
",",
"name",
",",
"recurse",
... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Scope.add_local | Add a local variable in the current scope
:field_name: The field's name
:field: The field
:returns: None | pfp/interp.py | def add_local(self, field_name, field):
"""Add a local variable in the current scope
:field_name: The field's name
:field: The field
:returns: None
"""
self._dlog("adding local '{}'".format(field_name))
field._pfp__name = field_name
# TODO do we allow cl... | def add_local(self, field_name, field):
"""Add a local variable in the current scope
:field_name: The field's name
:field: The field
:returns: None
"""
self._dlog("adding local '{}'".format(field_name))
field._pfp__name = field_name
# TODO do we allow cl... | [
"Add",
"a",
"local",
"variable",
"in",
"the",
"current",
"scope"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L353-L364 | [
"def",
"add_local",
"(",
"self",
",",
"field_name",
",",
"field",
")",
":",
"self",
".",
"_dlog",
"(",
"\"adding local '{}'\"",
".",
"format",
"(",
"field_name",
")",
")",
"field",
".",
"_pfp__name",
"=",
"field_name",
"# TODO do we allow clobbering of locals???",... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Scope.get_local | Get the local field (search for it) from the scope stack. An alias
for ``get_var``
:name: The name of the local field | pfp/interp.py | def get_local(self, name, recurse=True):
"""Get the local field (search for it) from the scope stack. An alias
for ``get_var``
:name: The name of the local field
"""
self._dlog("getting local '{}'".format(name))
return self._search("vars", name, recurse) | def get_local(self, name, recurse=True):
"""Get the local field (search for it) from the scope stack. An alias
for ``get_var``
:name: The name of the local field
"""
self._dlog("getting local '{}'".format(name))
return self._search("vars", name, recurse) | [
"Get",
"the",
"local",
"field",
"(",
"search",
"for",
"it",
")",
"from",
"the",
"scope",
"stack",
".",
"An",
"alias",
"for",
"get_var"
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L366-L373 | [
"def",
"get_local",
"(",
"self",
",",
"name",
",",
"recurse",
"=",
"True",
")",
":",
"self",
".",
"_dlog",
"(",
"\"getting local '{}'\"",
".",
"format",
"(",
"name",
")",
")",
"return",
"self",
".",
"_search",
"(",
"\"vars\"",
",",
"name",
",",
"recurs... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Scope.add_type_struct_or_union | Store the node with the name. When it is instantiated,
the node itself will be handled.
:name: name of the typedefd struct/union
:node: the union/struct node
:interp: the 010 interpreter | pfp/interp.py | def add_type_struct_or_union(self, name, interp, node):
"""Store the node with the name. When it is instantiated,
the node itself will be handled.
:name: name of the typedefd struct/union
:node: the union/struct node
:interp: the 010 interpreter
"""
self.add_type... | def add_type_struct_or_union(self, name, interp, node):
"""Store the node with the name. When it is instantiated,
the node itself will be handled.
:name: name of the typedefd struct/union
:node: the union/struct node
:interp: the 010 interpreter
"""
self.add_type... | [
"Store",
"the",
"node",
"with",
"the",
"name",
".",
"When",
"it",
"is",
"instantiated",
"the",
"node",
"itself",
"will",
"be",
"handled",
"."
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L380-L388 | [
"def",
"add_type_struct_or_union",
"(",
"self",
",",
"name",
",",
"interp",
",",
"node",
")",
":",
"self",
".",
"add_type_class",
"(",
"name",
",",
"StructUnionDef",
"(",
"name",
",",
"interp",
",",
"node",
")",
")"
] | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
train | Scope.add_type | Record the typedefd name for orig_names. Resolve orig_names
to their core names and save those.
:new_name: TODO
:orig_names: TODO
:returns: TODO | pfp/interp.py | def add_type(self, new_name, orig_names):
"""Record the typedefd name for orig_names. Resolve orig_names
to their core names and save those.
:new_name: TODO
:orig_names: TODO
:returns: TODO
"""
self._dlog("adding a type '{}'".format(new_name))
# TODO do ... | def add_type(self, new_name, orig_names):
"""Record the typedefd name for orig_names. Resolve orig_names
to their core names and save those.
:new_name: TODO
:orig_names: TODO
:returns: TODO
"""
self._dlog("adding a type '{}'".format(new_name))
# TODO do ... | [
"Record",
"the",
"typedefd",
"name",
"for",
"orig_names",
".",
"Resolve",
"orig_names",
"to",
"their",
"core",
"names",
"and",
"save",
"those",
"."
] | d0c-s4vage/pfp | python | https://github.com/d0c-s4vage/pfp/blob/32f2d34fdec1c70019fa83c7006d5e3be0f92fcd/pfp/interp.py#L390-L407 | [
"def",
"add_type",
"(",
"self",
",",
"new_name",
",",
"orig_names",
")",
":",
"self",
".",
"_dlog",
"(",
"\"adding a type '{}'\"",
".",
"format",
"(",
"new_name",
")",
")",
"# TODO do we allow clobbering of types???",
"res",
"=",
"copy",
".",
"copy",
"(",
"ori... | 32f2d34fdec1c70019fa83c7006d5e3be0f92fcd |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.