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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | wait_for_datacenter | Poll the data center to become available (for the next provisionig job) | examples/pb_deleteServer.py | def wait_for_datacenter(client, data_center_id):
'''
Poll the data center to become available (for the next provisionig job)
'''
total_sleep_time = 0
seconds = 5
while True:
state = client.get_datacenter(data_center_id)['metadata']['state']
if verbose:
print("datacent... | def wait_for_datacenter(client, data_center_id):
'''
Poll the data center to become available (for the next provisionig job)
'''
total_sleep_time = 0
seconds = 5
while True:
state = client.get_datacenter(data_center_id)['metadata']['state']
if verbose:
print("datacent... | [
"Poll",
"the",
"data",
"center",
"to",
"become",
"available",
"(",
"for",
"the",
"next",
"provisionig",
"job",
")"
] | profitbricks/profitbricks-sdk-python | python | https://github.com/profitbricks/profitbricks-sdk-python/blob/2c804b141688eccb07d6ae56601d5c60a62abebd/examples/pb_deleteServer.py#L209-L228 | [
"def",
"wait_for_datacenter",
"(",
"client",
",",
"data_center_id",
")",
":",
"total_sleep_time",
"=",
"0",
"seconds",
"=",
"5",
"while",
"True",
":",
"state",
"=",
"client",
".",
"get_datacenter",
"(",
"data_center_id",
")",
"[",
"'metadata'",
"]",
"[",
"'s... | 2c804b141688eccb07d6ae56601d5c60a62abebd |
valid | main | Command line options. | examples/pb_deleteServer.py | def main(argv=None):
'''Command line options.'''
if argv is None:
argv = sys.argv
else:
sys.argv.extend(argv)
program_name = os.path.basename(sys.argv[0])
program_version = "v%s" % __version__
program_build_date = str(__updated__)
program_version_message = '%%(prog)s %s (%s... | def main(argv=None):
'''Command line options.'''
if argv is None:
argv = sys.argv
else:
sys.argv.extend(argv)
program_name = os.path.basename(sys.argv[0])
program_version = "v%s" % __version__
program_build_date = str(__updated__)
program_version_message = '%%(prog)s %s (%s... | [
"Command",
"line",
"options",
"."
] | profitbricks/profitbricks-sdk-python | python | https://github.com/profitbricks/profitbricks-sdk-python/blob/2c804b141688eccb07d6ae56601d5c60a62abebd/examples/pb_deleteServer.py#L232-L336 | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"if",
"argv",
"is",
"None",
":",
"argv",
"=",
"sys",
".",
"argv",
"else",
":",
"sys",
".",
"argv",
".",
"extend",
"(",
"argv",
")",
"program_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
... | 2c804b141688eccb07d6ae56601d5c60a62abebd |
valid | getLogin | write user/passwd to login file or get them from file.
This method is not Py3 safe (byte vs. str) | examples/pb_addNewServer.py | def getLogin(filename, user, passwd):
'''
write user/passwd to login file or get them from file.
This method is not Py3 safe (byte vs. str)
'''
if filename is None:
return (user, passwd)
if os.path.exists(filename):
print("Using file {} for Login".format(filename))
with o... | def getLogin(filename, user, passwd):
'''
write user/passwd to login file or get them from file.
This method is not Py3 safe (byte vs. str)
'''
if filename is None:
return (user, passwd)
if os.path.exists(filename):
print("Using file {} for Login".format(filename))
with o... | [
"write",
"user",
"/",
"passwd",
"to",
"login",
"file",
"or",
"get",
"them",
"from",
"file",
".",
"This",
"method",
"is",
"not",
"Py3",
"safe",
"(",
"byte",
"vs",
".",
"str",
")"
] | profitbricks/profitbricks-sdk-python | python | https://github.com/profitbricks/profitbricks-sdk-python/blob/2c804b141688eccb07d6ae56601d5c60a62abebd/examples/pb_addNewServer.py#L71-L92 | [
"def",
"getLogin",
"(",
"filename",
",",
"user",
",",
"passwd",
")",
":",
"if",
"filename",
"is",
"None",
":",
"return",
"(",
"user",
",",
"passwd",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"filename",
")",
":",
"print",
"(",
"\"Using file {... | 2c804b141688eccb07d6ae56601d5c60a62abebd |
valid | wait_for_request | Waits for a request to finish until timeout.
timeout==0 is interpreted as infinite wait time.
Returns a tuple (return code, request status, message) where return code
0 : request successful
1 : request failed
-1 : timeout exceeded
The wait_period is increased every scaleup steps to adjust for ... | examples/pb_addNewServer.py | def wait_for_request(pbclient, request_id,
timeout=0, initial_wait=5, scaleup=10):
'''
Waits for a request to finish until timeout.
timeout==0 is interpreted as infinite wait time.
Returns a tuple (return code, request status, message) where return code
0 : request successful
... | def wait_for_request(pbclient, request_id,
timeout=0, initial_wait=5, scaleup=10):
'''
Waits for a request to finish until timeout.
timeout==0 is interpreted as infinite wait time.
Returns a tuple (return code, request status, message) where return code
0 : request successful
... | [
"Waits",
"for",
"a",
"request",
"to",
"finish",
"until",
"timeout",
".",
"timeout",
"==",
"0",
"is",
"interpreted",
"as",
"infinite",
"wait",
"time",
".",
"Returns",
"a",
"tuple",
"(",
"return",
"code",
"request",
"status",
"message",
")",
"where",
"return... | profitbricks/profitbricks-sdk-python | python | https://github.com/profitbricks/profitbricks-sdk-python/blob/2c804b141688eccb07d6ae56601d5c60a62abebd/examples/pb_addNewServer.py#L96-L134 | [
"def",
"wait_for_request",
"(",
"pbclient",
",",
"request_id",
",",
"timeout",
"=",
"0",
",",
"initial_wait",
"=",
"5",
",",
"scaleup",
"=",
"10",
")",
":",
"total_wait",
"=",
"0",
"wait_period",
"=",
"initial_wait",
"next_scaleup",
"=",
"scaleup",
"*",
"w... | 2c804b141688eccb07d6ae56601d5c60a62abebd |
valid | main | Parse command line options and create a server/volume composite. | examples/pb_addNewServer.py | def main(argv=None):
'''Parse command line options and create a server/volume composite.'''
if argv is None:
argv = sys.argv
else:
sys.argv.extend(argv)
program_name = os.path.basename(sys.argv[0])
program_version = "v%s" % __version__
program_build_date = str(__updated__)
... | def main(argv=None):
'''Parse command line options and create a server/volume composite.'''
if argv is None:
argv = sys.argv
else:
sys.argv.extend(argv)
program_name = os.path.basename(sys.argv[0])
program_version = "v%s" % __version__
program_build_date = str(__updated__)
... | [
"Parse",
"command",
"line",
"options",
"and",
"create",
"a",
"server",
"/",
"volume",
"composite",
"."
] | profitbricks/profitbricks-sdk-python | python | https://github.com/profitbricks/profitbricks-sdk-python/blob/2c804b141688eccb07d6ae56601d5c60a62abebd/examples/pb_addNewServer.py#L138-L261 | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"if",
"argv",
"is",
"None",
":",
"argv",
"=",
"sys",
".",
"argv",
"else",
":",
"sys",
".",
"argv",
".",
"extend",
"(",
"argv",
")",
"program_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
... | 2c804b141688eccb07d6ae56601d5c60a62abebd |
valid | main | Command line options. | examples/pb_controlServerState.py | def main(argv=None):
'''Command line options.'''
if argv is None:
argv = sys.argv
else:
sys.argv.extend(argv)
program_name = os.path.basename(sys.argv[0])
program_version = "v%s" % __version__
program_build_date = str(__updated__)
program_version_message = '%%(prog)s %s (%s... | def main(argv=None):
'''Command line options.'''
if argv is None:
argv = sys.argv
else:
sys.argv.extend(argv)
program_name = os.path.basename(sys.argv[0])
program_version = "v%s" % __version__
program_build_date = str(__updated__)
program_version_message = '%%(prog)s %s (%s... | [
"Command",
"line",
"options",
"."
] | profitbricks/profitbricks-sdk-python | python | https://github.com/profitbricks/profitbricks-sdk-python/blob/2c804b141688eccb07d6ae56601d5c60a62abebd/examples/pb_controlServerState.py#L209-L354 | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"if",
"argv",
"is",
"None",
":",
"argv",
"=",
"sys",
".",
"argv",
"else",
":",
"sys",
".",
"argv",
".",
"extend",
"(",
"argv",
")",
"program_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
... | 2c804b141688eccb07d6ae56601d5c60a62abebd |
valid | get_dc_inventory | gets inventory of one data center | examples/pb_datacenter_inventory.py | def get_dc_inventory(pbclient, dc=None):
''' gets inventory of one data center'''
if pbclient is None:
raise ValueError("argument 'pbclient' must not be None")
if dc is None:
raise ValueError("argument 'dc' must not be None")
dc_inv = [] # inventory list to return
dcid = dc['id']
... | def get_dc_inventory(pbclient, dc=None):
''' gets inventory of one data center'''
if pbclient is None:
raise ValueError("argument 'pbclient' must not be None")
if dc is None:
raise ValueError("argument 'dc' must not be None")
dc_inv = [] # inventory list to return
dcid = dc['id']
... | [
"gets",
"inventory",
"of",
"one",
"data",
"center"
] | profitbricks/profitbricks-sdk-python | python | https://github.com/profitbricks/profitbricks-sdk-python/blob/2c804b141688eccb07d6ae56601d5c60a62abebd/examples/pb_datacenter_inventory.py#L106-L184 | [
"def",
"get_dc_inventory",
"(",
"pbclient",
",",
"dc",
"=",
"None",
")",
":",
"if",
"pbclient",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"argument 'pbclient' must not be None\"",
")",
"if",
"dc",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"argume... | 2c804b141688eccb07d6ae56601d5c60a62abebd |
valid | get_dc_network | gets inventory of one data center | examples/pb_datacenter_inventory.py | def get_dc_network(pbclient, dc=None):
''' gets inventory of one data center'''
if pbclient is None:
raise ValueError("argument 'pbclient' must not be None")
if dc is None:
raise ValueError("argument 'dc' must not be None")
print("getting networks..")
dcid = dc['id']
# dc_data co... | def get_dc_network(pbclient, dc=None):
''' gets inventory of one data center'''
if pbclient is None:
raise ValueError("argument 'pbclient' must not be None")
if dc is None:
raise ValueError("argument 'dc' must not be None")
print("getting networks..")
dcid = dc['id']
# dc_data co... | [
"gets",
"inventory",
"of",
"one",
"data",
"center"
] | profitbricks/profitbricks-sdk-python | python | https://github.com/profitbricks/profitbricks-sdk-python/blob/2c804b141688eccb07d6ae56601d5c60a62abebd/examples/pb_datacenter_inventory.py#L257-L315 | [
"def",
"get_dc_network",
"(",
"pbclient",
",",
"dc",
"=",
"None",
")",
":",
"if",
"pbclient",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"argument 'pbclient' must not be None\"",
")",
"if",
"dc",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"\"argument... | 2c804b141688eccb07d6ae56601d5c60a62abebd |
valid | main | Command line options. | examples/pb_datacenter_inventory.py | def main(argv=None): # IGNORE:C0111
'''Command line options.'''
if argv is None:
argv = sys.argv
else:
sys.argv.extend(argv)
program_name = os.path.basename(sys.argv[0])
program_version = "v%s" % __version__
program_build_date = str(__updated__)
program_versi... | def main(argv=None): # IGNORE:C0111
'''Command line options.'''
if argv is None:
argv = sys.argv
else:
sys.argv.extend(argv)
program_name = os.path.basename(sys.argv[0])
program_version = "v%s" % __version__
program_build_date = str(__updated__)
program_versi... | [
"Command",
"line",
"options",
"."
] | profitbricks/profitbricks-sdk-python | python | https://github.com/profitbricks/profitbricks-sdk-python/blob/2c804b141688eccb07d6ae56601d5c60a62abebd/examples/pb_datacenter_inventory.py#L345-L510 | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"# IGNORE:C0111",
"if",
"argv",
"is",
"None",
":",
"argv",
"=",
"sys",
".",
"argv",
"else",
":",
"sys",
".",
"argv",
".",
"extend",
"(",
"argv",
")",
"program_name",
"=",
"os",
".",
"path",
".",
... | 2c804b141688eccb07d6ae56601d5c60a62abebd |
valid | main | Parse command line options and dump a datacenter to snapshots and file. | examples/pb_snapshotDatacenter.py | def main(argv=None):
'''Parse command line options and dump a datacenter to snapshots and file.'''
if argv is None:
argv = sys.argv
else:
sys.argv.extend(argv)
program_name = os.path.basename(sys.argv[0])
program_version = "v%s" % __version__
program_build_date = str(__updated_... | def main(argv=None):
'''Parse command line options and dump a datacenter to snapshots and file.'''
if argv is None:
argv = sys.argv
else:
sys.argv.extend(argv)
program_name = os.path.basename(sys.argv[0])
program_version = "v%s" % __version__
program_build_date = str(__updated_... | [
"Parse",
"command",
"line",
"options",
"and",
"dump",
"a",
"datacenter",
"to",
"snapshots",
"and",
"file",
"."
] | profitbricks/profitbricks-sdk-python | python | https://github.com/profitbricks/profitbricks-sdk-python/blob/2c804b141688eccb07d6ae56601d5c60a62abebd/examples/pb_snapshotDatacenter.py#L393-L588 | [
"def",
"main",
"(",
"argv",
"=",
"None",
")",
":",
"if",
"argv",
"is",
"None",
":",
"argv",
"=",
"sys",
".",
"argv",
"else",
":",
"sys",
".",
"argv",
".",
"extend",
"(",
"argv",
")",
"program_name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
... | 2c804b141688eccb07d6ae56601d5c60a62abebd |
valid | get_self | Get details about the currently authenticated user | freelancersdk/resources/users/users.py | def get_self(session, user_details=None):
"""
Get details about the currently authenticated user
"""
# Set compact to true
if user_details:
user_details['compact'] = True
response = make_get_request(session, 'self', params_data=user_details)
json_data = response.json()
if respons... | def get_self(session, user_details=None):
"""
Get details about the currently authenticated user
"""
# Set compact to true
if user_details:
user_details['compact'] = True
response = make_get_request(session, 'self', params_data=user_details)
json_data = response.json()
if respons... | [
"Get",
"details",
"about",
"the",
"currently",
"authenticated",
"user"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/users/users.py#L12-L28 | [
"def",
"get_self",
"(",
"session",
",",
"user_details",
"=",
"None",
")",
":",
"# Set compact to true",
"if",
"user_details",
":",
"user_details",
"[",
"'compact'",
"]",
"=",
"True",
"response",
"=",
"make_get_request",
"(",
"session",
",",
"'self'",
",",
"par... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | get_user_by_id | Get details about specific user | freelancersdk/resources/users/users.py | def get_user_by_id(session, user_id, user_details=None):
"""
Get details about specific user
"""
if user_details:
user_details['compact'] = True
response = make_get_request(
session, 'users/{}'.format(user_id), params_data=user_details)
json_data = response.json()
if response... | def get_user_by_id(session, user_id, user_details=None):
"""
Get details about specific user
"""
if user_details:
user_details['compact'] = True
response = make_get_request(
session, 'users/{}'.format(user_id), params_data=user_details)
json_data = response.json()
if response... | [
"Get",
"details",
"about",
"specific",
"user"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/users/users.py#L31-L47 | [
"def",
"get_user_by_id",
"(",
"session",
",",
"user_id",
",",
"user_details",
"=",
"None",
")",
":",
"if",
"user_details",
":",
"user_details",
"[",
"'compact'",
"]",
"=",
"True",
"response",
"=",
"make_get_request",
"(",
"session",
",",
"'users/{}'",
".",
"... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | get_self_user_id | Get the currently authenticated user ID | freelancersdk/resources/users/users.py | def get_self_user_id(session):
"""
Get the currently authenticated user ID
"""
response = make_get_request(session, 'self')
if response.status_code == 200:
return response.json()['result']['id']
else:
raise UserIdNotRetrievedException(
'Error retrieving user id: %s' %... | def get_self_user_id(session):
"""
Get the currently authenticated user ID
"""
response = make_get_request(session, 'self')
if response.status_code == 200:
return response.json()['result']['id']
else:
raise UserIdNotRetrievedException(
'Error retrieving user id: %s' %... | [
"Get",
"the",
"currently",
"authenticated",
"user",
"ID"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/users/users.py#L50-L59 | [
"def",
"get_self_user_id",
"(",
"session",
")",
":",
"response",
"=",
"make_get_request",
"(",
"session",
",",
"'self'",
")",
"if",
"response",
".",
"status_code",
"==",
"200",
":",
"return",
"response",
".",
"json",
"(",
")",
"[",
"'result'",
"]",
"[",
... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | add_user_jobs | Add a list of jobs to the currently authenticated user | freelancersdk/resources/users/users.py | def add_user_jobs(session, job_ids):
"""
Add a list of jobs to the currently authenticated user
"""
jobs_data = {
'jobs[]': job_ids
}
response = make_post_request(session, 'self/jobs', json_data=jobs_data)
json_data = response.json()
if response.status_code == 200:
return... | def add_user_jobs(session, job_ids):
"""
Add a list of jobs to the currently authenticated user
"""
jobs_data = {
'jobs[]': job_ids
}
response = make_post_request(session, 'self/jobs', json_data=jobs_data)
json_data = response.json()
if response.status_code == 200:
return... | [
"Add",
"a",
"list",
"of",
"jobs",
"to",
"the",
"currently",
"authenticated",
"user"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/users/users.py#L62-L77 | [
"def",
"add_user_jobs",
"(",
"session",
",",
"job_ids",
")",
":",
"jobs_data",
"=",
"{",
"'jobs[]'",
":",
"job_ids",
"}",
"response",
"=",
"make_post_request",
"(",
"session",
",",
"'self/jobs'",
",",
"json_data",
"=",
"jobs_data",
")",
"json_data",
"=",
"re... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | set_user_jobs | Replace the currently authenticated user's list of jobs with a new list of
jobs | freelancersdk/resources/users/users.py | def set_user_jobs(session, job_ids):
"""
Replace the currently authenticated user's list of jobs with a new list of
jobs
"""
jobs_data = {
'jobs[]': job_ids
}
response = make_put_request(session, 'self/jobs', json_data=jobs_data)
json_data = response.json()
if response.status... | def set_user_jobs(session, job_ids):
"""
Replace the currently authenticated user's list of jobs with a new list of
jobs
"""
jobs_data = {
'jobs[]': job_ids
}
response = make_put_request(session, 'self/jobs', json_data=jobs_data)
json_data = response.json()
if response.status... | [
"Replace",
"the",
"currently",
"authenticated",
"user",
"s",
"list",
"of",
"jobs",
"with",
"a",
"new",
"list",
"of",
"jobs"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/users/users.py#L80-L96 | [
"def",
"set_user_jobs",
"(",
"session",
",",
"job_ids",
")",
":",
"jobs_data",
"=",
"{",
"'jobs[]'",
":",
"job_ids",
"}",
"response",
"=",
"make_put_request",
"(",
"session",
",",
"'self/jobs'",
",",
"json_data",
"=",
"jobs_data",
")",
"json_data",
"=",
"res... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | delete_user_jobs | Remove a list of jobs from the currently authenticated user | freelancersdk/resources/users/users.py | def delete_user_jobs(session, job_ids):
"""
Remove a list of jobs from the currently authenticated user
"""
jobs_data = {
'jobs[]': job_ids
}
response = make_delete_request(session, 'self/jobs', json_data=jobs_data)
json_data = response.json()
if response.status_code == 200:
... | def delete_user_jobs(session, job_ids):
"""
Remove a list of jobs from the currently authenticated user
"""
jobs_data = {
'jobs[]': job_ids
}
response = make_delete_request(session, 'self/jobs', json_data=jobs_data)
json_data = response.json()
if response.status_code == 200:
... | [
"Remove",
"a",
"list",
"of",
"jobs",
"from",
"the",
"currently",
"authenticated",
"user"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/users/users.py#L99-L114 | [
"def",
"delete_user_jobs",
"(",
"session",
",",
"job_ids",
")",
":",
"jobs_data",
"=",
"{",
"'jobs[]'",
":",
"job_ids",
"}",
"response",
"=",
"make_delete_request",
"(",
"session",
",",
"'self/jobs'",
",",
"json_data",
"=",
"jobs_data",
")",
"json_data",
"=",
... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | get_users | Get one or more users | freelancersdk/resources/users/users.py | def get_users(session, query):
"""
Get one or more users
"""
# GET /api/users/0.1/users
response = make_get_request(session, 'users', params_data=query)
json_data = response.json()
if response.status_code == 200:
return json_data['result']
else:
raise UsersNotFoundExcepti... | def get_users(session, query):
"""
Get one or more users
"""
# GET /api/users/0.1/users
response = make_get_request(session, 'users', params_data=query)
json_data = response.json()
if response.status_code == 200:
return json_data['result']
else:
raise UsersNotFoundExcepti... | [
"Get",
"one",
"or",
"more",
"users"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/users/users.py#L117-L130 | [
"def",
"get_users",
"(",
"session",
",",
"query",
")",
":",
"# GET /api/users/0.1/users",
"response",
"=",
"make_get_request",
"(",
"session",
",",
"'users'",
",",
"params_data",
"=",
"query",
")",
"json_data",
"=",
"response",
".",
"json",
"(",
")",
"if",
"... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | create_project | Create a project | freelancersdk/resources/projects/projects.py | def create_project(session, title, description,
currency, budget, jobs):
"""
Create a project
"""
project_data = {'title': title,
'description': description,
'currency': currency,
'budget': budget,
'jobs':... | def create_project(session, title, description,
currency, budget, jobs):
"""
Create a project
"""
project_data = {'title': title,
'description': description,
'currency': currency,
'budget': budget,
'jobs':... | [
"Create",
"a",
"project"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L38-L62 | [
"def",
"create_project",
"(",
"session",
",",
"title",
",",
"description",
",",
"currency",
",",
"budget",
",",
"jobs",
")",
":",
"project_data",
"=",
"{",
"'title'",
":",
"title",
",",
"'description'",
":",
"description",
",",
"'currency'",
":",
"currency",... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | create_hireme_project | Create a fixed project | freelancersdk/resources/projects/projects.py | def create_hireme_project(session, title, description,
currency, budget, jobs, hireme_initial_bid):
"""
Create a fixed project
"""
jobs.append(create_job_object(id=417)) # Hire Me job, required
project_data = {'title': title,
'description': description... | def create_hireme_project(session, title, description,
currency, budget, jobs, hireme_initial_bid):
"""
Create a fixed project
"""
jobs.append(create_job_object(id=417)) # Hire Me job, required
project_data = {'title': title,
'description': description... | [
"Create",
"a",
"fixed",
"project"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L123-L151 | [
"def",
"create_hireme_project",
"(",
"session",
",",
"title",
",",
"description",
",",
"currency",
",",
"budget",
",",
"jobs",
",",
"hireme_initial_bid",
")",
":",
"jobs",
".",
"append",
"(",
"create_job_object",
"(",
"id",
"=",
"417",
")",
")",
"# Hire Me j... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | get_projects | Get one or more projects | freelancersdk/resources/projects/projects.py | def get_projects(session, query):
"""
Get one or more projects
"""
# GET /api/projects/0.1/projects
response = make_get_request(session, 'projects', params_data=query)
json_data = response.json()
if response.status_code == 200:
return json_data['result']
else:
raise Proje... | def get_projects(session, query):
"""
Get one or more projects
"""
# GET /api/projects/0.1/projects
response = make_get_request(session, 'projects', params_data=query)
json_data = response.json()
if response.status_code == 200:
return json_data['result']
else:
raise Proje... | [
"Get",
"one",
"or",
"more",
"projects"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L154-L167 | [
"def",
"get_projects",
"(",
"session",
",",
"query",
")",
":",
"# GET /api/projects/0.1/projects",
"response",
"=",
"make_get_request",
"(",
"session",
",",
"'projects'",
",",
"params_data",
"=",
"query",
")",
"json_data",
"=",
"response",
".",
"json",
"(",
")",... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | get_project_by_id | Get a single project by ID | freelancersdk/resources/projects/projects.py | def get_project_by_id(session, project_id, project_details=None, user_details=None):
"""
Get a single project by ID
"""
# GET /api/projects/0.1/projects/<int:project_id>
query = {}
if project_details:
query.update(project_details)
if user_details:
query.update(user_details)
... | def get_project_by_id(session, project_id, project_details=None, user_details=None):
"""
Get a single project by ID
"""
# GET /api/projects/0.1/projects/<int:project_id>
query = {}
if project_details:
query.update(project_details)
if user_details:
query.update(user_details)
... | [
"Get",
"a",
"single",
"project",
"by",
"ID"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L170-L190 | [
"def",
"get_project_by_id",
"(",
"session",
",",
"project_id",
",",
"project_details",
"=",
"None",
",",
"user_details",
"=",
"None",
")",
":",
"# GET /api/projects/0.1/projects/<int:project_id>",
"query",
"=",
"{",
"}",
"if",
"project_details",
":",
"query",
".",
... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | search_projects | Search for all projects | freelancersdk/resources/projects/projects.py | def search_projects(session,
query,
search_filter=None,
project_details=None,
user_details=None,
limit=10,
offset=0,
active_only=None):
"""
Search for all projects
"""
... | def search_projects(session,
query,
search_filter=None,
project_details=None,
user_details=None,
limit=10,
offset=0,
active_only=None):
"""
Search for all projects
"""
... | [
"Search",
"for",
"all",
"projects"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L193-L227 | [
"def",
"search_projects",
"(",
"session",
",",
"query",
",",
"search_filter",
"=",
"None",
",",
"project_details",
"=",
"None",
",",
"user_details",
"=",
"None",
",",
"limit",
"=",
"10",
",",
"offset",
"=",
"0",
",",
"active_only",
"=",
"None",
")",
":",... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | place_project_bid | Place a bid on a project | freelancersdk/resources/projects/projects.py | def place_project_bid(session, project_id, bidder_id, description, amount,
period, milestone_percentage):
"""
Place a bid on a project
"""
bid_data = {
'project_id': project_id,
'bidder_id': bidder_id,
'description': description,
'amount': amount,
... | def place_project_bid(session, project_id, bidder_id, description, amount,
period, milestone_percentage):
"""
Place a bid on a project
"""
bid_data = {
'project_id': project_id,
'bidder_id': bidder_id,
'description': description,
'amount': amount,
... | [
"Place",
"a",
"bid",
"on",
"a",
"project"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L230-L252 | [
"def",
"place_project_bid",
"(",
"session",
",",
"project_id",
",",
"bidder_id",
",",
"description",
",",
"amount",
",",
"period",
",",
"milestone_percentage",
")",
":",
"bid_data",
"=",
"{",
"'project_id'",
":",
"project_id",
",",
"'bidder_id'",
":",
"bidder_id... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | get_bids | Get the list of bids | freelancersdk/resources/projects/projects.py | def get_bids(session, project_ids=[], bid_ids=[], limit=10, offset=0):
"""
Get the list of bids
"""
get_bids_data = {}
if bid_ids:
get_bids_data['bids[]'] = bid_ids
if project_ids:
get_bids_data['projects[]'] = project_ids
get_bids_data['limit'] = limit
get_bids_data['off... | def get_bids(session, project_ids=[], bid_ids=[], limit=10, offset=0):
"""
Get the list of bids
"""
get_bids_data = {}
if bid_ids:
get_bids_data['bids[]'] = bid_ids
if project_ids:
get_bids_data['projects[]'] = project_ids
get_bids_data['limit'] = limit
get_bids_data['off... | [
"Get",
"the",
"list",
"of",
"bids"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L255-L275 | [
"def",
"get_bids",
"(",
"session",
",",
"project_ids",
"=",
"[",
"]",
",",
"bid_ids",
"=",
"[",
"]",
",",
"limit",
"=",
"10",
",",
"offset",
"=",
"0",
")",
":",
"get_bids_data",
"=",
"{",
"}",
"if",
"bid_ids",
":",
"get_bids_data",
"[",
"'bids[]'",
... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | get_milestones | Get the list of milestones | freelancersdk/resources/projects/projects.py | def get_milestones(session, project_ids=[], milestone_ids=[], user_details=None, limit=10, offset=0):
"""
Get the list of milestones
"""
get_milestones_data = {}
if milestone_ids:
get_milestones_data['milestones[]'] = milestone_ids
if project_ids:
get_milestones_data['projects[]'... | def get_milestones(session, project_ids=[], milestone_ids=[], user_details=None, limit=10, offset=0):
"""
Get the list of milestones
"""
get_milestones_data = {}
if milestone_ids:
get_milestones_data['milestones[]'] = milestone_ids
if project_ids:
get_milestones_data['projects[]'... | [
"Get",
"the",
"list",
"of",
"milestones"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L278-L306 | [
"def",
"get_milestones",
"(",
"session",
",",
"project_ids",
"=",
"[",
"]",
",",
"milestone_ids",
"=",
"[",
"]",
",",
"user_details",
"=",
"None",
",",
"limit",
"=",
"10",
",",
"offset",
"=",
"0",
")",
":",
"get_milestones_data",
"=",
"{",
"}",
"if",
... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | get_milestone_by_id | Get a specific milestone | freelancersdk/resources/projects/projects.py | def get_milestone_by_id(session, milestone_id, user_details=None):
"""
Get a specific milestone
"""
# GET /api/projects/0.1/milestones/{milestone_id}/
endpoint = 'milestones/{}'.format(milestone_id)
response = make_get_request(session, endpoint, params_data=user_details)
json_data = respons... | def get_milestone_by_id(session, milestone_id, user_details=None):
"""
Get a specific milestone
"""
# GET /api/projects/0.1/milestones/{milestone_id}/
endpoint = 'milestones/{}'.format(milestone_id)
response = make_get_request(session, endpoint, params_data=user_details)
json_data = respons... | [
"Get",
"a",
"specific",
"milestone"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L309-L325 | [
"def",
"get_milestone_by_id",
"(",
"session",
",",
"milestone_id",
",",
"user_details",
"=",
"None",
")",
":",
"# GET /api/projects/0.1/milestones/{milestone_id}/",
"endpoint",
"=",
"'milestones/{}'",
".",
"format",
"(",
"milestone_id",
")",
"response",
"=",
"make_get_r... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | award_project_bid | Award a bid on a project | freelancersdk/resources/projects/projects.py | def award_project_bid(session, bid_id):
"""
Award a bid on a project
"""
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
bid_data = {
'action': 'award'
}
# POST /api/projects/0.1/bids/{bid_id}/?action=award
endpoint = 'bids/{}'.format(bid_id)
res... | def award_project_bid(session, bid_id):
"""
Award a bid on a project
"""
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
bid_data = {
'action': 'award'
}
# POST /api/projects/0.1/bids/{bid_id}/?action=award
endpoint = 'bids/{}'.format(bid_id)
res... | [
"Award",
"a",
"bid",
"on",
"a",
"project"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L328-L351 | [
"def",
"award_project_bid",
"(",
"session",
",",
"bid_id",
")",
":",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'application/x-www-form-urlencoded'",
"}",
"bid_data",
"=",
"{",
"'action'",
":",
"'award'",
"}",
"# POST /api/projects/0.1/bids/{bid_id}/?action=award",
"e... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | revoke_project_bid | Revoke a bid on a project | freelancersdk/resources/projects/projects.py | def revoke_project_bid(session, bid_id):
"""
Revoke a bid on a project
"""
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
bid_data = {
'action': 'revoke'
}
# POST /api/projects/0.1/bids/{bid_id}/?action=revoke
endpoint = 'bids/{}'.format(bid_id)
... | def revoke_project_bid(session, bid_id):
"""
Revoke a bid on a project
"""
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
bid_data = {
'action': 'revoke'
}
# POST /api/projects/0.1/bids/{bid_id}/?action=revoke
endpoint = 'bids/{}'.format(bid_id)
... | [
"Revoke",
"a",
"bid",
"on",
"a",
"project"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L354-L375 | [
"def",
"revoke_project_bid",
"(",
"session",
",",
"bid_id",
")",
":",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'application/x-www-form-urlencoded'",
"}",
"bid_data",
"=",
"{",
"'action'",
":",
"'revoke'",
"}",
"# POST /api/projects/0.1/bids/{bid_id}/?action=revoke",
... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | accept_project_bid | Accept a bid on a project | freelancersdk/resources/projects/projects.py | def accept_project_bid(session, bid_id):
"""
Accept a bid on a project
"""
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
bid_data = {
'action': 'accept'
}
# POST /api/projects/0.1/bids/{bid_id}/?action=revoke
endpoint = 'bids/{}'.format(bid_id)
... | def accept_project_bid(session, bid_id):
"""
Accept a bid on a project
"""
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
bid_data = {
'action': 'accept'
}
# POST /api/projects/0.1/bids/{bid_id}/?action=revoke
endpoint = 'bids/{}'.format(bid_id)
... | [
"Accept",
"a",
"bid",
"on",
"a",
"project"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L378-L399 | [
"def",
"accept_project_bid",
"(",
"session",
",",
"bid_id",
")",
":",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'application/x-www-form-urlencoded'",
"}",
"bid_data",
"=",
"{",
"'action'",
":",
"'accept'",
"}",
"# POST /api/projects/0.1/bids/{bid_id}/?action=revoke",
... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | retract_project_bid | Retract a bid on a project | freelancersdk/resources/projects/projects.py | def retract_project_bid(session, bid_id):
"""
Retract a bid on a project
"""
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
bid_data = {
'action': 'retract'
}
# POST /api/projects/0.1/bids/{bid_id}/?action=revoke
endpoint = 'bids/{}'.format(bid_id)
... | def retract_project_bid(session, bid_id):
"""
Retract a bid on a project
"""
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
bid_data = {
'action': 'retract'
}
# POST /api/projects/0.1/bids/{bid_id}/?action=revoke
endpoint = 'bids/{}'.format(bid_id)
... | [
"Retract",
"a",
"bid",
"on",
"a",
"project"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L402-L423 | [
"def",
"retract_project_bid",
"(",
"session",
",",
"bid_id",
")",
":",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'application/x-www-form-urlencoded'",
"}",
"bid_data",
"=",
"{",
"'action'",
":",
"'retract'",
"}",
"# POST /api/projects/0.1/bids/{bid_id}/?action=revoke",... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | highlight_project_bid | Highlight a bid on a project | freelancersdk/resources/projects/projects.py | def highlight_project_bid(session, bid_id):
"""
Highlight a bid on a project
"""
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
bid_data = {
'action': 'highlight'
}
# POST /api/projects/0.1/bids/{bid_id}/?action=revoke
endpoint = 'bids/{}'.format(bi... | def highlight_project_bid(session, bid_id):
"""
Highlight a bid on a project
"""
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
bid_data = {
'action': 'highlight'
}
# POST /api/projects/0.1/bids/{bid_id}/?action=revoke
endpoint = 'bids/{}'.format(bi... | [
"Highlight",
"a",
"bid",
"on",
"a",
"project"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L426-L447 | [
"def",
"highlight_project_bid",
"(",
"session",
",",
"bid_id",
")",
":",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'application/x-www-form-urlencoded'",
"}",
"bid_data",
"=",
"{",
"'action'",
":",
"'highlight'",
"}",
"# POST /api/projects/0.1/bids/{bid_id}/?action=revo... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | create_milestone_payment | Create a milestone payment | freelancersdk/resources/projects/projects.py | def create_milestone_payment(session, project_id, bidder_id, amount,
reason, description):
"""
Create a milestone payment
"""
milestone_data = {
'project_id': project_id,
'bidder_id': bidder_id,
'amount': amount,
'reason': reason,
'des... | def create_milestone_payment(session, project_id, bidder_id, amount,
reason, description):
"""
Create a milestone payment
"""
milestone_data = {
'project_id': project_id,
'bidder_id': bidder_id,
'amount': amount,
'reason': reason,
'des... | [
"Create",
"a",
"milestone",
"payment"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L450-L472 | [
"def",
"create_milestone_payment",
"(",
"session",
",",
"project_id",
",",
"bidder_id",
",",
"amount",
",",
"reason",
",",
"description",
")",
":",
"milestone_data",
"=",
"{",
"'project_id'",
":",
"project_id",
",",
"'bidder_id'",
":",
"bidder_id",
",",
"'amount... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | post_track | Start tracking a project by creating a track | freelancersdk/resources/projects/projects.py | def post_track(session, user_id, project_id, latitude, longitude):
"""
Start tracking a project by creating a track
"""
tracking_data = {
'user_id': user_id,
'project_id': project_id,
'track_point': {
'latitude': latitude,
'longitude': longitude
}
... | def post_track(session, user_id, project_id, latitude, longitude):
"""
Start tracking a project by creating a track
"""
tracking_data = {
'user_id': user_id,
'project_id': project_id,
'track_point': {
'latitude': latitude,
'longitude': longitude
}
... | [
"Start",
"tracking",
"a",
"project",
"by",
"creating",
"a",
"track"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L475-L497 | [
"def",
"post_track",
"(",
"session",
",",
"user_id",
",",
"project_id",
",",
"latitude",
",",
"longitude",
")",
":",
"tracking_data",
"=",
"{",
"'user_id'",
":",
"user_id",
",",
"'project_id'",
":",
"project_id",
",",
"'track_point'",
":",
"{",
"'latitude'",
... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | update_track | Updates the current location by creating a new track point and appending
it to the given track | freelancersdk/resources/projects/projects.py | def update_track(session, track_id, latitude, longitude, stop_tracking=False):
"""
Updates the current location by creating a new track point and appending
it to the given track
"""
tracking_data = {
'track_point': {
'latitude': latitude,
'longitude': longitude,
... | def update_track(session, track_id, latitude, longitude, stop_tracking=False):
"""
Updates the current location by creating a new track point and appending
it to the given track
"""
tracking_data = {
'track_point': {
'latitude': latitude,
'longitude': longitude,
... | [
"Updates",
"the",
"current",
"location",
"by",
"creating",
"a",
"new",
"track",
"point",
"and",
"appending",
"it",
"to",
"the",
"given",
"track"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L500-L524 | [
"def",
"update_track",
"(",
"session",
",",
"track_id",
",",
"latitude",
",",
"longitude",
",",
"stop_tracking",
"=",
"False",
")",
":",
"tracking_data",
"=",
"{",
"'track_point'",
":",
"{",
"'latitude'",
":",
"latitude",
",",
"'longitude'",
":",
"longitude",
... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | get_track_by_id | Gets a specific track | freelancersdk/resources/projects/projects.py | def get_track_by_id(session, track_id, track_point_limit=None, track_point_offset=None):
"""
Gets a specific track
"""
tracking_data = {}
if track_point_limit:
tracking_data['track_point_limit'] = track_point_limit
if track_point_offset:
tracking_data['track_point_offset'] = tra... | def get_track_by_id(session, track_id, track_point_limit=None, track_point_offset=None):
"""
Gets a specific track
"""
tracking_data = {}
if track_point_limit:
tracking_data['track_point_limit'] = track_point_limit
if track_point_offset:
tracking_data['track_point_offset'] = tra... | [
"Gets",
"a",
"specific",
"track"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L527-L548 | [
"def",
"get_track_by_id",
"(",
"session",
",",
"track_id",
",",
"track_point_limit",
"=",
"None",
",",
"track_point_offset",
"=",
"None",
")",
":",
"tracking_data",
"=",
"{",
"}",
"if",
"track_point_limit",
":",
"tracking_data",
"[",
"'track_point_limit'",
"]",
... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | release_milestone_payment | Release a milestone payment | freelancersdk/resources/projects/projects.py | def release_milestone_payment(session, milestone_id, amount):
"""
Release a milestone payment
"""
params_data = {
'action': 'release',
}
milestone_data = {
'amount': amount,
}
# PUT /api/projects/0.1/milestones/{milestone_id}/?action=release
endpoint = 'milestones/{}'... | def release_milestone_payment(session, milestone_id, amount):
"""
Release a milestone payment
"""
params_data = {
'action': 'release',
}
milestone_data = {
'amount': amount,
}
# PUT /api/projects/0.1/milestones/{milestone_id}/?action=release
endpoint = 'milestones/{}'... | [
"Release",
"a",
"milestone",
"payment"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L551-L571 | [
"def",
"release_milestone_payment",
"(",
"session",
",",
"milestone_id",
",",
"amount",
")",
":",
"params_data",
"=",
"{",
"'action'",
":",
"'release'",
",",
"}",
"milestone_data",
"=",
"{",
"'amount'",
":",
"amount",
",",
"}",
"# PUT /api/projects/0.1/milestones/... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | request_release_milestone_payment | Release a milestone payment | freelancersdk/resources/projects/projects.py | def request_release_milestone_payment(session, milestone_id):
"""
Release a milestone payment
"""
params_data = {
'action': 'request_release',
}
# PUT /api/projects/0.1/milestones/{milestone_id}/?action=release
endpoint = 'milestones/{}'.format(milestone_id)
response = make_put_r... | def request_release_milestone_payment(session, milestone_id):
"""
Release a milestone payment
"""
params_data = {
'action': 'request_release',
}
# PUT /api/projects/0.1/milestones/{milestone_id}/?action=release
endpoint = 'milestones/{}'.format(milestone_id)
response = make_put_r... | [
"Release",
"a",
"milestone",
"payment"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L574-L591 | [
"def",
"request_release_milestone_payment",
"(",
"session",
",",
"milestone_id",
")",
":",
"params_data",
"=",
"{",
"'action'",
":",
"'request_release'",
",",
"}",
"# PUT /api/projects/0.1/milestones/{milestone_id}/?action=release",
"endpoint",
"=",
"'milestones/{}'",
".",
... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | cancel_milestone_payment | Release a milestone payment | freelancersdk/resources/projects/projects.py | def cancel_milestone_payment(session, milestone_id):
"""
Release a milestone payment
"""
params_data = {
'action': 'cancel',
}
# PUT /api/projects/0.1/milestones/{milestone_id}/?action=release
endpoint = 'milestones/{}'.format(milestone_id)
response = make_put_request(session, en... | def cancel_milestone_payment(session, milestone_id):
"""
Release a milestone payment
"""
params_data = {
'action': 'cancel',
}
# PUT /api/projects/0.1/milestones/{milestone_id}/?action=release
endpoint = 'milestones/{}'.format(milestone_id)
response = make_put_request(session, en... | [
"Release",
"a",
"milestone",
"payment"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L594-L611 | [
"def",
"cancel_milestone_payment",
"(",
"session",
",",
"milestone_id",
")",
":",
"params_data",
"=",
"{",
"'action'",
":",
"'cancel'",
",",
"}",
"# PUT /api/projects/0.1/milestones/{milestone_id}/?action=release",
"endpoint",
"=",
"'milestones/{}'",
".",
"format",
"(",
... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | create_milestone_request | Create a milestone request | freelancersdk/resources/projects/projects.py | def create_milestone_request(session, project_id, bid_id, description, amount):
"""
Create a milestone request
"""
milestone_request_data = {
'project_id': project_id,
'bid_id': bid_id,
'description': description,
'amount': amount,
}
# POST /api/projects/0.1/miles... | def create_milestone_request(session, project_id, bid_id, description, amount):
"""
Create a milestone request
"""
milestone_request_data = {
'project_id': project_id,
'bid_id': bid_id,
'description': description,
'amount': amount,
}
# POST /api/projects/0.1/miles... | [
"Create",
"a",
"milestone",
"request"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L614-L635 | [
"def",
"create_milestone_request",
"(",
"session",
",",
"project_id",
",",
"bid_id",
",",
"description",
",",
"amount",
")",
":",
"milestone_request_data",
"=",
"{",
"'project_id'",
":",
"project_id",
",",
"'bid_id'",
":",
"bid_id",
",",
"'description'",
":",
"d... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | accept_milestone_request | Accept a milestone request | freelancersdk/resources/projects/projects.py | def accept_milestone_request(session, milestone_request_id):
"""
Accept a milestone request
"""
params_data = {
'action': 'accept',
}
# POST /api/projects/0.1/milestone_requests/{milestone_request_id}/?action=
# accept
endpoint = 'milestone_requests/{}'.format(milestone_request_i... | def accept_milestone_request(session, milestone_request_id):
"""
Accept a milestone request
"""
params_data = {
'action': 'accept',
}
# POST /api/projects/0.1/milestone_requests/{milestone_request_id}/?action=
# accept
endpoint = 'milestone_requests/{}'.format(milestone_request_i... | [
"Accept",
"a",
"milestone",
"request"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L638-L656 | [
"def",
"accept_milestone_request",
"(",
"session",
",",
"milestone_request_id",
")",
":",
"params_data",
"=",
"{",
"'action'",
":",
"'accept'",
",",
"}",
"# POST /api/projects/0.1/milestone_requests/{milestone_request_id}/?action=",
"# accept",
"endpoint",
"=",
"'milestone_re... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | reject_milestone_request | Reject a milestone request | freelancersdk/resources/projects/projects.py | def reject_milestone_request(session, milestone_request_id):
"""
Reject a milestone request
"""
params_data = {
'action': 'reject',
}
# POST /api/projects/0.1/milestone_requests/{milestone_request_id}/?action=
# reject
endpoint = 'milestone_requests/{}'.format(milestone_request_i... | def reject_milestone_request(session, milestone_request_id):
"""
Reject a milestone request
"""
params_data = {
'action': 'reject',
}
# POST /api/projects/0.1/milestone_requests/{milestone_request_id}/?action=
# reject
endpoint = 'milestone_requests/{}'.format(milestone_request_i... | [
"Reject",
"a",
"milestone",
"request"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L659-L677 | [
"def",
"reject_milestone_request",
"(",
"session",
",",
"milestone_request_id",
")",
":",
"params_data",
"=",
"{",
"'action'",
":",
"'reject'",
",",
"}",
"# POST /api/projects/0.1/milestone_requests/{milestone_request_id}/?action=",
"# reject",
"endpoint",
"=",
"'milestone_re... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | delete_milestone_request | Delete a milestone request | freelancersdk/resources/projects/projects.py | def delete_milestone_request(session, milestone_request_id):
"""
Delete a milestone request
"""
params_data = {
'action': 'delete',
}
# POST /api/projects/0.1/milestone_requests/{milestone_request_id}/?action=
# delete
endpoint = 'milestone_requests/{}'.format(milestone_request_i... | def delete_milestone_request(session, milestone_request_id):
"""
Delete a milestone request
"""
params_data = {
'action': 'delete',
}
# POST /api/projects/0.1/milestone_requests/{milestone_request_id}/?action=
# delete
endpoint = 'milestone_requests/{}'.format(milestone_request_i... | [
"Delete",
"a",
"milestone",
"request"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L680-L698 | [
"def",
"delete_milestone_request",
"(",
"session",
",",
"milestone_request_id",
")",
":",
"params_data",
"=",
"{",
"'action'",
":",
"'delete'",
",",
"}",
"# POST /api/projects/0.1/milestone_requests/{milestone_request_id}/?action=",
"# delete",
"endpoint",
"=",
"'milestone_re... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | post_review | Post a review | freelancersdk/resources/projects/projects.py | def post_review(session, review):
"""
Post a review
"""
# POST /api/projects/0.1/reviews/
response = make_post_request(session, 'reviews', json_data=review)
json_data = response.json()
if response.status_code == 200:
return json_data['status']
else:
raise ReviewNotPostedE... | def post_review(session, review):
"""
Post a review
"""
# POST /api/projects/0.1/reviews/
response = make_post_request(session, 'reviews', json_data=review)
json_data = response.json()
if response.status_code == 200:
return json_data['status']
else:
raise ReviewNotPostedE... | [
"Post",
"a",
"review"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L701-L714 | [
"def",
"post_review",
"(",
"session",
",",
"review",
")",
":",
"# POST /api/projects/0.1/reviews/",
"response",
"=",
"make_post_request",
"(",
"session",
",",
"'reviews'",
",",
"json_data",
"=",
"review",
")",
"json_data",
"=",
"response",
".",
"json",
"(",
")",... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | get_jobs | Get a list of jobs | freelancersdk/resources/projects/projects.py | def get_jobs(session, job_ids, seo_details, lang):
"""
Get a list of jobs
"""
get_jobs_data = {
'jobs[]': job_ids,
'seo_details': seo_details,
'lang': lang,
}
# GET /api/projects/0.1/jobs/
response = make_get_request(session, 'jobs', params_data=get_jobs_data)
jso... | def get_jobs(session, job_ids, seo_details, lang):
"""
Get a list of jobs
"""
get_jobs_data = {
'jobs[]': job_ids,
'seo_details': seo_details,
'lang': lang,
}
# GET /api/projects/0.1/jobs/
response = make_get_request(session, 'jobs', params_data=get_jobs_data)
jso... | [
"Get",
"a",
"list",
"of",
"jobs"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/projects/projects.py#L717-L735 | [
"def",
"get_jobs",
"(",
"session",
",",
"job_ids",
",",
"seo_details",
",",
"lang",
")",
":",
"get_jobs_data",
"=",
"{",
"'jobs[]'",
":",
"job_ids",
",",
"'seo_details'",
":",
"seo_details",
",",
"'lang'",
":",
"lang",
",",
"}",
"# GET /api/projects/0.1/jobs/"... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | create_thread | Create a thread | freelancersdk/resources/messages/messages.py | def create_thread(session, member_ids, context_type, context, message):
"""
Create a thread
"""
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
thread_data = {
'members[]': member_ids,
'context_type': context_type,
'context': context,
'me... | def create_thread(session, member_ids, context_type, context, message):
"""
Create a thread
"""
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
thread_data = {
'members[]': member_ids,
'context_type': context_type,
'context': context,
'me... | [
"Create",
"a",
"thread"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/messages/messages.py#L17-L40 | [
"def",
"create_thread",
"(",
"session",
",",
"member_ids",
",",
"context_type",
",",
"context",
",",
"message",
")",
":",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'application/x-www-form-urlencoded'",
"}",
"thread_data",
"=",
"{",
"'members[]'",
":",
"member_i... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | create_project_thread | Create a project thread | freelancersdk/resources/messages/messages.py | def create_project_thread(session, member_ids, project_id, message):
"""
Create a project thread
"""
return create_thread(session, member_ids, 'project', project_id, message) | def create_project_thread(session, member_ids, project_id, message):
"""
Create a project thread
"""
return create_thread(session, member_ids, 'project', project_id, message) | [
"Create",
"a",
"project",
"thread"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/messages/messages.py#L43-L47 | [
"def",
"create_project_thread",
"(",
"session",
",",
"member_ids",
",",
"project_id",
",",
"message",
")",
":",
"return",
"create_thread",
"(",
"session",
",",
"member_ids",
",",
"'project'",
",",
"project_id",
",",
"message",
")"
] | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | post_message | Add a message to a thread | freelancersdk/resources/messages/messages.py | def post_message(session, thread_id, message):
"""
Add a message to a thread
"""
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
message_data = {
'message': message,
}
# POST /api/messages/0.1/threads/{thread_id}/messages/
endpoint = 'threads/{}/mes... | def post_message(session, thread_id, message):
"""
Add a message to a thread
"""
headers = {
'Content-Type': 'application/x-www-form-urlencoded'
}
message_data = {
'message': message,
}
# POST /api/messages/0.1/threads/{thread_id}/messages/
endpoint = 'threads/{}/mes... | [
"Add",
"a",
"message",
"to",
"a",
"thread"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/messages/messages.py#L50-L71 | [
"def",
"post_message",
"(",
"session",
",",
"thread_id",
",",
"message",
")",
":",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'application/x-www-form-urlencoded'",
"}",
"message_data",
"=",
"{",
"'message'",
":",
"message",
",",
"}",
"# POST /api/messages/0.1/thre... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | post_attachment | Add a message to a thread | freelancersdk/resources/messages/messages.py | def post_attachment(session, thread_id, attachments):
"""
Add a message to a thread
"""
files = []
filenames = []
for attachment in attachments:
files.append(attachment['file'])
filenames.append(attachment['filename'])
message_data = {
'attachments[]': filenames,
... | def post_attachment(session, thread_id, attachments):
"""
Add a message to a thread
"""
files = []
filenames = []
for attachment in attachments:
files.append(attachment['file'])
filenames.append(attachment['filename'])
message_data = {
'attachments[]': filenames,
... | [
"Add",
"a",
"message",
"to",
"a",
"thread"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/messages/messages.py#L74-L97 | [
"def",
"post_attachment",
"(",
"session",
",",
"thread_id",
",",
"attachments",
")",
":",
"files",
"=",
"[",
"]",
"filenames",
"=",
"[",
"]",
"for",
"attachment",
"in",
"attachments",
":",
"files",
".",
"append",
"(",
"attachment",
"[",
"'file'",
"]",
")... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | get_messages | Get one or more messages | freelancersdk/resources/messages/messages.py | def get_messages(session, query, limit=10, offset=0):
"""
Get one or more messages
"""
query['limit'] = limit
query['offset'] = offset
# GET /api/messages/0.1/messages
response = make_get_request(session, 'messages', params_data=query)
json_data = response.json()
if response.status_... | def get_messages(session, query, limit=10, offset=0):
"""
Get one or more messages
"""
query['limit'] = limit
query['offset'] = offset
# GET /api/messages/0.1/messages
response = make_get_request(session, 'messages', params_data=query)
json_data = response.json()
if response.status_... | [
"Get",
"one",
"or",
"more",
"messages"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/messages/messages.py#L100-L117 | [
"def",
"get_messages",
"(",
"session",
",",
"query",
",",
"limit",
"=",
"10",
",",
"offset",
"=",
"0",
")",
":",
"query",
"[",
"'limit'",
"]",
"=",
"limit",
"query",
"[",
"'offset'",
"]",
"=",
"offset",
"# GET /api/messages/0.1/messages",
"response",
"=",
... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | search_messages | Search for messages | freelancersdk/resources/messages/messages.py | def search_messages(session, thread_id, query, limit=20,
offset=0, message_context_details=None,
window_above=None, window_below=None):
"""
Search for messages
"""
query = {
'thread_id': thread_id,
'query': query,
'limit': limit,
'o... | def search_messages(session, thread_id, query, limit=20,
offset=0, message_context_details=None,
window_above=None, window_below=None):
"""
Search for messages
"""
query = {
'thread_id': thread_id,
'query': query,
'limit': limit,
'o... | [
"Search",
"for",
"messages"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/messages/messages.py#L120-L149 | [
"def",
"search_messages",
"(",
"session",
",",
"thread_id",
",",
"query",
",",
"limit",
"=",
"20",
",",
"offset",
"=",
"0",
",",
"message_context_details",
"=",
"None",
",",
"window_above",
"=",
"None",
",",
"window_below",
"=",
"None",
")",
":",
"query",
... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | get_threads | Get one or more threads | freelancersdk/resources/messages/messages.py | def get_threads(session, query):
"""
Get one or more threads
"""
# GET /api/messages/0.1/threads
response = make_get_request(session, 'threads', params_data=query)
json_data = response.json()
if response.status_code == 200:
return json_data['result']
else:
raise ThreadsNo... | def get_threads(session, query):
"""
Get one or more threads
"""
# GET /api/messages/0.1/threads
response = make_get_request(session, 'threads', params_data=query)
json_data = response.json()
if response.status_code == 200:
return json_data['result']
else:
raise ThreadsNo... | [
"Get",
"one",
"or",
"more",
"threads"
] | freelancer/freelancer-sdk-python | python | https://github.com/freelancer/freelancer-sdk-python/blob/e09034936d6f13b3909a9464ee329c81c1834941/freelancersdk/resources/messages/messages.py#L152-L166 | [
"def",
"get_threads",
"(",
"session",
",",
"query",
")",
":",
"# GET /api/messages/0.1/threads",
"response",
"=",
"make_get_request",
"(",
"session",
",",
"'threads'",
",",
"params_data",
"=",
"query",
")",
"json_data",
"=",
"response",
".",
"json",
"(",
")",
... | e09034936d6f13b3909a9464ee329c81c1834941 |
valid | _clean | Assumes zipcode is of type `str` | zipcodes/__init__.py | def _clean(zipcode, valid_length=_valid_zipcode_length):
""" Assumes zipcode is of type `str` """
zipcode = zipcode.split("-")[0] # Convert #####-#### to #####
if len(zipcode) != valid_length:
raise ValueError(
'Invalid format, zipcode must be of the format: "#####" or "#####-####"'
... | def _clean(zipcode, valid_length=_valid_zipcode_length):
""" Assumes zipcode is of type `str` """
zipcode = zipcode.split("-")[0] # Convert #####-#### to #####
if len(zipcode) != valid_length:
raise ValueError(
'Invalid format, zipcode must be of the format: "#####" or "#####-####"'
... | [
"Assumes",
"zipcode",
"is",
"of",
"type",
"str"
] | seanpianka/Zipcodes | python | https://github.com/seanpianka/Zipcodes/blob/c815226de7a12e659f3198a23de942e354c8a001/zipcodes/__init__.py#L48-L60 | [
"def",
"_clean",
"(",
"zipcode",
",",
"valid_length",
"=",
"_valid_zipcode_length",
")",
":",
"zipcode",
"=",
"zipcode",
".",
"split",
"(",
"\"-\"",
")",
"[",
"0",
"]",
"# Convert #####-#### to #####",
"if",
"len",
"(",
"zipcode",
")",
"!=",
"valid_length",
... | c815226de7a12e659f3198a23de942e354c8a001 |
valid | similar_to | List of zipcode dicts where zipcode prefix matches `partial_zipcode` | zipcodes/__init__.py | def similar_to(partial_zipcode, zips=_zips):
""" List of zipcode dicts where zipcode prefix matches `partial_zipcode` """
return [z for z in zips if z["zip_code"].startswith(partial_zipcode)] | def similar_to(partial_zipcode, zips=_zips):
""" List of zipcode dicts where zipcode prefix matches `partial_zipcode` """
return [z for z in zips if z["zip_code"].startswith(partial_zipcode)] | [
"List",
"of",
"zipcode",
"dicts",
"where",
"zipcode",
"prefix",
"matches",
"partial_zipcode"
] | seanpianka/Zipcodes | python | https://github.com/seanpianka/Zipcodes/blob/c815226de7a12e659f3198a23de942e354c8a001/zipcodes/__init__.py#L82-L84 | [
"def",
"similar_to",
"(",
"partial_zipcode",
",",
"zips",
"=",
"_zips",
")",
":",
"return",
"[",
"z",
"for",
"z",
"in",
"zips",
"if",
"z",
"[",
"\"zip_code\"",
"]",
".",
"startswith",
"(",
"partial_zipcode",
")",
"]"
] | c815226de7a12e659f3198a23de942e354c8a001 |
valid | filter_by | Use `kwargs` to select for desired attributes from list of zipcode dicts | zipcodes/__init__.py | def filter_by(zips=_zips, **kwargs):
""" Use `kwargs` to select for desired attributes from list of zipcode dicts """
return [z for z in zips if all([k in z and z[k] == v for k, v in kwargs.items()])] | def filter_by(zips=_zips, **kwargs):
""" Use `kwargs` to select for desired attributes from list of zipcode dicts """
return [z for z in zips if all([k in z and z[k] == v for k, v in kwargs.items()])] | [
"Use",
"kwargs",
"to",
"select",
"for",
"desired",
"attributes",
"from",
"list",
"of",
"zipcode",
"dicts"
] | seanpianka/Zipcodes | python | https://github.com/seanpianka/Zipcodes/blob/c815226de7a12e659f3198a23de942e354c8a001/zipcodes/__init__.py#L87-L89 | [
"def",
"filter_by",
"(",
"zips",
"=",
"_zips",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"[",
"z",
"for",
"z",
"in",
"zips",
"if",
"all",
"(",
"[",
"k",
"in",
"z",
"and",
"z",
"[",
"k",
"]",
"==",
"v",
"for",
"k",
",",
"v",
"in",
"kwargs... | c815226de7a12e659f3198a23de942e354c8a001 |
valid | is_valid_identifier | Pedantic yet imperfect. Test to see if "name" is a valid python identifier | urwid_utils/util.py | def is_valid_identifier(name):
"""Pedantic yet imperfect. Test to see if "name" is a valid python identifier
"""
if not isinstance(name, str):
return False
if '\n' in name:
return False
if name.strip() != name:
return False
try:
code = compile('\n{0}=None'.format(... | def is_valid_identifier(name):
"""Pedantic yet imperfect. Test to see if "name" is a valid python identifier
"""
if not isinstance(name, str):
return False
if '\n' in name:
return False
if name.strip() != name:
return False
try:
code = compile('\n{0}=None'.format(... | [
"Pedantic",
"yet",
"imperfect",
".",
"Test",
"to",
"see",
"if",
"name",
"is",
"a",
"valid",
"python",
"identifier"
] | tonycpsu/urwid_utils | python | https://github.com/tonycpsu/urwid_utils/blob/d6cf4eddc0469a762aab708891b03cd0d94b322d/urwid_utils/util.py#L7-L21 | [
"def",
"is_valid_identifier",
"(",
"name",
")",
":",
"if",
"not",
"isinstance",
"(",
"name",
",",
"str",
")",
":",
"return",
"False",
"if",
"'\\n'",
"in",
"name",
":",
"return",
"False",
"if",
"name",
".",
"strip",
"(",
")",
"!=",
"name",
":",
"retur... | d6cf4eddc0469a762aab708891b03cd0d94b322d |
valid | PaletteEntry.from_config | Build a palette definition from either a simple string or a dictionary,
filling in defaults for items not specified.
e.g.:
"dark green"
dark green foreground, black background
{lo: dark gray, hi: "#666"}
dark gray on 16-color terminals, #666 for ... | urwid_utils/palette.py | def from_config(
cls, cfg,
default_fg=DEFAULT_FG_16, default_bg=DEFAULT_BG_16,
default_fg_hi=DEFAULT_FG_256, default_bg_hi=DEFAULT_BG_256,
max_colors=2**24
):
"""
Build a palette definition from either a simple string or a dictionary,
filling i... | def from_config(
cls, cfg,
default_fg=DEFAULT_FG_16, default_bg=DEFAULT_BG_16,
default_fg_hi=DEFAULT_FG_256, default_bg_hi=DEFAULT_BG_256,
max_colors=2**24
):
"""
Build a palette definition from either a simple string or a dictionary,
filling i... | [
"Build",
"a",
"palette",
"definition",
"from",
"either",
"a",
"simple",
"string",
"or",
"a",
"dictionary",
"filling",
"in",
"defaults",
"for",
"items",
"not",
"specified",
"."
] | tonycpsu/urwid_utils | python | https://github.com/tonycpsu/urwid_utils/blob/d6cf4eddc0469a762aab708891b03cd0d94b322d/urwid_utils/palette.py#L45-L115 | [
"def",
"from_config",
"(",
"cls",
",",
"cfg",
",",
"default_fg",
"=",
"DEFAULT_FG_16",
",",
"default_bg",
"=",
"DEFAULT_BG_16",
",",
"default_fg_hi",
"=",
"DEFAULT_FG_256",
",",
"default_bg_hi",
"=",
"DEFAULT_BG_256",
",",
"max_colors",
"=",
"2",
"**",
"24",
"... | d6cf4eddc0469a762aab708891b03cd0d94b322d |
valid | get_passphrase | Return a passphrase as found in a passphrase.ghost file
Lookup is done in three locations on non-Windows systems and two on Windows
All:
`cwd/passphrase.ghost`
`~/.ghost/passphrase.ghost`
Only non-Windows:
`/etc/ghost/passphrase.ghost` | ghost.py | def get_passphrase(passphrase=None):
"""Return a passphrase as found in a passphrase.ghost file
Lookup is done in three locations on non-Windows systems and two on Windows
All:
`cwd/passphrase.ghost`
`~/.ghost/passphrase.ghost`
Only non-Windows:
`/etc/ghost/passphrase.ghost`
... | def get_passphrase(passphrase=None):
"""Return a passphrase as found in a passphrase.ghost file
Lookup is done in three locations on non-Windows systems and two on Windows
All:
`cwd/passphrase.ghost`
`~/.ghost/passphrase.ghost`
Only non-Windows:
`/etc/ghost/passphrase.ghost`
... | [
"Return",
"a",
"passphrase",
"as",
"found",
"in",
"a",
"passphrase",
".",
"ghost",
"file"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L139-L153 | [
"def",
"get_passphrase",
"(",
"passphrase",
"=",
"None",
")",
":",
"for",
"passphrase_file_path",
"in",
"POTENTIAL_PASSPHRASE_LOCATIONS",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"passphrase_file_path",
")",
":",
"with",
"open",
"(",
"passphrase_file_path... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | migrate | Migrate all keys in a source stash to a destination stash
The migration process will decrypt all keys using the source
stash's passphrase and then encrypt them based on the destination
stash's passphrase.
re-encryption will take place only if the passphrases are differing | ghost.py | def migrate(src_path,
src_passphrase,
src_backend,
dst_path,
dst_passphrase,
dst_backend):
"""Migrate all keys in a source stash to a destination stash
The migration process will decrypt all keys using the source
stash's passphrase and then encryp... | def migrate(src_path,
src_passphrase,
src_backend,
dst_path,
dst_passphrase,
dst_backend):
"""Migrate all keys in a source stash to a destination stash
The migration process will decrypt all keys using the source
stash's passphrase and then encryp... | [
"Migrate",
"all",
"keys",
"in",
"a",
"source",
"stash",
"to",
"a",
"destination",
"stash"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L583-L604 | [
"def",
"migrate",
"(",
"src_path",
",",
"src_passphrase",
",",
"src_backend",
",",
"dst_path",
",",
"dst_passphrase",
",",
"dst_backend",
")",
":",
"src_storage",
"=",
"STORAGE_MAPPING",
"[",
"src_backend",
"]",
"(",
"*",
"*",
"_parse_path_string",
"(",
"src_pat... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | generate_passphrase | Return a generate string `size` long based on lowercase, uppercase,
and digit chars | ghost.py | def generate_passphrase(size=12):
"""Return a generate string `size` long based on lowercase, uppercase,
and digit chars
"""
chars = string.ascii_lowercase + string.ascii_uppercase + string.digits
return str(''.join(random.choice(chars) for _ in range(size))) | def generate_passphrase(size=12):
"""Return a generate string `size` long based on lowercase, uppercase,
and digit chars
"""
chars = string.ascii_lowercase + string.ascii_uppercase + string.digits
return str(''.join(random.choice(chars) for _ in range(size))) | [
"Return",
"a",
"generate",
"string",
"size",
"long",
"based",
"on",
"lowercase",
"uppercase",
"and",
"digit",
"chars"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1122-L1127 | [
"def",
"generate_passphrase",
"(",
"size",
"=",
"12",
")",
":",
"chars",
"=",
"string",
".",
"ascii_lowercase",
"+",
"string",
".",
"ascii_uppercase",
"+",
"string",
".",
"digits",
"return",
"str",
"(",
"''",
".",
"join",
"(",
"random",
".",
"choice",
"(... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | _build_dict_from_key_value | Return a dict from a list of key=value pairs | ghost.py | def _build_dict_from_key_value(keys_and_values):
"""Return a dict from a list of key=value pairs
"""
key_dict = {}
for key_value in keys_and_values:
if '=' not in key_value:
raise GhostError('Pair {0} is not of `key=value` format'.format(
key_value))
key, valu... | def _build_dict_from_key_value(keys_and_values):
"""Return a dict from a list of key=value pairs
"""
key_dict = {}
for key_value in keys_and_values:
if '=' not in key_value:
raise GhostError('Pair {0} is not of `key=value` format'.format(
key_value))
key, valu... | [
"Return",
"a",
"dict",
"from",
"a",
"list",
"of",
"key",
"=",
"value",
"pairs"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1134-L1144 | [
"def",
"_build_dict_from_key_value",
"(",
"keys_and_values",
")",
":",
"key_dict",
"=",
"{",
"}",
"for",
"key_value",
"in",
"keys_and_values",
":",
"if",
"'='",
"not",
"in",
"key_value",
":",
"raise",
"GhostError",
"(",
"'Pair {0} is not of `key=value` format'",
"."... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | _prettify_dict | Return a human readable format of a key (dict).
Example:
Description: My Wonderful Key
Uid: a54d6de1-922a-4998-ad34-cb838646daaa
Created_At: 2016-09-15T12:42:32
Metadata: owner=me;
Modified_At: 2016-09-15T12:42:32
Value: secret_key=my_secret_key;access_key=my_... | ghost.py | def _prettify_dict(key):
"""Return a human readable format of a key (dict).
Example:
Description: My Wonderful Key
Uid: a54d6de1-922a-4998-ad34-cb838646daaa
Created_At: 2016-09-15T12:42:32
Metadata: owner=me;
Modified_At: 2016-09-15T12:42:32
Value: secret_... | def _prettify_dict(key):
"""Return a human readable format of a key (dict).
Example:
Description: My Wonderful Key
Uid: a54d6de1-922a-4998-ad34-cb838646daaa
Created_At: 2016-09-15T12:42:32
Metadata: owner=me;
Modified_At: 2016-09-15T12:42:32
Value: secret_... | [
"Return",
"a",
"human",
"readable",
"format",
"of",
"a",
"key",
"(",
"dict",
")",
"."
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1147-L1170 | [
"def",
"_prettify_dict",
"(",
"key",
")",
":",
"assert",
"isinstance",
"(",
"key",
",",
"dict",
")",
"pretty_key",
"=",
"''",
"for",
"key",
",",
"value",
"in",
"key",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"dict",
")",
... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | _prettify_list | Return a human readable format of a list.
Example:
Available Keys:
- my_first_key
- my_second_key | ghost.py | def _prettify_list(items):
"""Return a human readable format of a list.
Example:
Available Keys:
- my_first_key
- my_second_key
"""
assert isinstance(items, list)
keys_list = 'Available Keys:'
for item in items:
keys_list += '\n - {0}'.format(item)
return keys_lis... | def _prettify_list(items):
"""Return a human readable format of a list.
Example:
Available Keys:
- my_first_key
- my_second_key
"""
assert isinstance(items, list)
keys_list = 'Available Keys:'
for item in items:
keys_list += '\n - {0}'.format(item)
return keys_lis... | [
"Return",
"a",
"human",
"readable",
"format",
"of",
"a",
"list",
"."
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1173-L1187 | [
"def",
"_prettify_list",
"(",
"items",
")",
":",
"assert",
"isinstance",
"(",
"items",
",",
"list",
")",
"keys_list",
"=",
"'Available Keys:'",
"for",
"item",
"in",
"items",
":",
"keys_list",
"+=",
"'\\n - {0}'",
".",
"format",
"(",
"item",
")",
"return",
... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | init_stash | r"""Init a stash
`STASH_PATH` is the path to the storage endpoint. If this isn't supplied,
a default path will be used. In the path, you can specify a name
for the stash (which, if omitted, will default to `ghost`) like so:
`ghost init http://10.10.1.1:8500;stash1`.
After initializing a stash, don... | ghost.py | def init_stash(stash_path, passphrase, passphrase_size, backend):
r"""Init a stash
`STASH_PATH` is the path to the storage endpoint. If this isn't supplied,
a default path will be used. In the path, you can specify a name
for the stash (which, if omitted, will default to `ghost`) like so:
`ghost in... | def init_stash(stash_path, passphrase, passphrase_size, backend):
r"""Init a stash
`STASH_PATH` is the path to the storage endpoint. If this isn't supplied,
a default path will be used. In the path, you can specify a name
for the stash (which, if omitted, will default to `ghost`) like so:
`ghost in... | [
"r",
"Init",
"a",
"stash"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1278-L1339 | [
"def",
"init_stash",
"(",
"stash_path",
",",
"passphrase",
",",
"passphrase_size",
",",
"backend",
")",
":",
"stash_path",
"=",
"stash_path",
"or",
"STORAGE_DEFAULT_PATH_MAPPING",
"[",
"backend",
"]",
"click",
".",
"echo",
"(",
"'Stash: {0} at {1}'",
".",
"format"... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | put_key | Insert a key to the stash
`KEY_NAME` is the name of the key to insert
`VALUE` is a key=value argument which can be provided multiple times.
it is the encrypted value of your key | ghost.py | def put_key(key_name,
value,
description,
meta,
modify,
add,
lock,
key_type,
stash,
passphrase,
backend):
"""Insert a key to the stash
`KEY_NAME` is the name of the key to insert
`VALUE`... | def put_key(key_name,
value,
description,
meta,
modify,
add,
lock,
key_type,
stash,
passphrase,
backend):
"""Insert a key to the stash
`KEY_NAME` is the name of the key to insert
`VALUE`... | [
"Insert",
"a",
"key",
"to",
"the",
"stash"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1373-L1406 | [
"def",
"put_key",
"(",
"key_name",
",",
"value",
",",
"description",
",",
"meta",
",",
"modify",
",",
"add",
",",
"lock",
",",
"key_type",
",",
"stash",
",",
"passphrase",
",",
"backend",
")",
":",
"stash",
"=",
"_get_stash",
"(",
"backend",
",",
"stas... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | lock_key | Lock a key to prevent it from being deleted, purged or modified
`KEY_NAME` is the name of the key to lock | ghost.py | def lock_key(key_name,
stash,
passphrase,
backend):
"""Lock a key to prevent it from being deleted, purged or modified
`KEY_NAME` is the name of the key to lock
"""
stash = _get_stash(backend, stash, passphrase)
try:
click.echo('Locking key...')
... | def lock_key(key_name,
stash,
passphrase,
backend):
"""Lock a key to prevent it from being deleted, purged or modified
`KEY_NAME` is the name of the key to lock
"""
stash = _get_stash(backend, stash, passphrase)
try:
click.echo('Locking key...')
... | [
"Lock",
"a",
"key",
"to",
"prevent",
"it",
"from",
"being",
"deleted",
"purged",
"or",
"modified"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1414-L1429 | [
"def",
"lock_key",
"(",
"key_name",
",",
"stash",
",",
"passphrase",
",",
"backend",
")",
":",
"stash",
"=",
"_get_stash",
"(",
"backend",
",",
"stash",
",",
"passphrase",
")",
"try",
":",
"click",
".",
"echo",
"(",
"'Locking key...'",
")",
"stash",
".",... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | unlock_key | Unlock a key to allow it to be modified, deleted or purged
`KEY_NAME` is the name of the key to unlock | ghost.py | def unlock_key(key_name,
stash,
passphrase,
backend):
"""Unlock a key to allow it to be modified, deleted or purged
`KEY_NAME` is the name of the key to unlock
"""
stash = _get_stash(backend, stash, passphrase)
try:
click.echo('Unlocking key...'... | def unlock_key(key_name,
stash,
passphrase,
backend):
"""Unlock a key to allow it to be modified, deleted or purged
`KEY_NAME` is the name of the key to unlock
"""
stash = _get_stash(backend, stash, passphrase)
try:
click.echo('Unlocking key...'... | [
"Unlock",
"a",
"key",
"to",
"allow",
"it",
"to",
"be",
"modified",
"deleted",
"or",
"purged"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1437-L1452 | [
"def",
"unlock_key",
"(",
"key_name",
",",
"stash",
",",
"passphrase",
",",
"backend",
")",
":",
"stash",
"=",
"_get_stash",
"(",
"backend",
",",
"stash",
",",
"passphrase",
")",
"try",
":",
"click",
".",
"echo",
"(",
"'Unlocking key...'",
")",
"stash",
... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | get_key | Retrieve a key from the stash
\b
`KEY_NAME` is the name of the key to retrieve
`VALUE_NAME` is a single value to retrieve e.g. if the value
of the key `test` is `a=b,b=c`, `ghost get test a`a will return
`b` | ghost.py | def get_key(key_name,
value_name,
jsonify,
no_decrypt,
stash,
passphrase,
backend):
"""Retrieve a key from the stash
\b
`KEY_NAME` is the name of the key to retrieve
`VALUE_NAME` is a single value to retrieve e.g. if the value
... | def get_key(key_name,
value_name,
jsonify,
no_decrypt,
stash,
passphrase,
backend):
"""Retrieve a key from the stash
\b
`KEY_NAME` is the name of the key to retrieve
`VALUE_NAME` is a single value to retrieve e.g. if the value
... | [
"Retrieve",
"a",
"key",
"from",
"the",
"stash"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1470-L1510 | [
"def",
"get_key",
"(",
"key_name",
",",
"value_name",
",",
"jsonify",
",",
"no_decrypt",
",",
"stash",
",",
"passphrase",
",",
"backend",
")",
":",
"if",
"value_name",
"and",
"no_decrypt",
":",
"sys",
".",
"exit",
"(",
"'VALUE_NAME cannot be used in conjuction w... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | delete_key | Delete a key from the stash
`KEY_NAME` is the name of the key to delete
You can provide that multiple times to delete multiple keys at once | ghost.py | def delete_key(key_name, stash, passphrase, backend):
"""Delete a key from the stash
`KEY_NAME` is the name of the key to delete
You can provide that multiple times to delete multiple keys at once
"""
stash = _get_stash(backend, stash, passphrase)
for key in key_name:
try:
... | def delete_key(key_name, stash, passphrase, backend):
"""Delete a key from the stash
`KEY_NAME` is the name of the key to delete
You can provide that multiple times to delete multiple keys at once
"""
stash = _get_stash(backend, stash, passphrase)
for key in key_name:
try:
... | [
"Delete",
"a",
"key",
"from",
"the",
"stash"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1518-L1532 | [
"def",
"delete_key",
"(",
"key_name",
",",
"stash",
",",
"passphrase",
",",
"backend",
")",
":",
"stash",
"=",
"_get_stash",
"(",
"backend",
",",
"stash",
",",
"passphrase",
")",
"for",
"key",
"in",
"key_name",
":",
"try",
":",
"click",
".",
"echo",
"(... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | list_keys | List all keys in the stash
If `KEY_NAME` is provided, will look for keys containing `KEY_NAME`.
If `KEY_NAME` starts with `~`, close matches will be provided according
to `max_suggestions` and `cutoff`. | ghost.py | def list_keys(key_name,
max_suggestions,
cutoff,
jsonify,
locked,
key_type,
stash,
passphrase,
backend):
"""List all keys in the stash
If `KEY_NAME` is provided, will look for keys containing `KEY_NA... | def list_keys(key_name,
max_suggestions,
cutoff,
jsonify,
locked,
key_type,
stash,
passphrase,
backend):
"""List all keys in the stash
If `KEY_NAME` is provided, will look for keys containing `KEY_NA... | [
"List",
"all",
"keys",
"in",
"the",
"stash"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1561-L1593 | [
"def",
"list_keys",
"(",
"key_name",
",",
"max_suggestions",
",",
"cutoff",
",",
"jsonify",
",",
"locked",
",",
"key_type",
",",
"stash",
",",
"passphrase",
",",
"backend",
")",
":",
"stash",
"=",
"_get_stash",
"(",
"backend",
",",
"stash",
",",
"passphras... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | purge_stash | Purge the stash from all of its keys | ghost.py | def purge_stash(force, stash, passphrase, backend):
"""Purge the stash from all of its keys
"""
stash = _get_stash(backend, stash, passphrase)
try:
click.echo('Purging stash...')
stash.purge(force)
# Maybe we should verify that the list is empty
# afterwards?
cli... | def purge_stash(force, stash, passphrase, backend):
"""Purge the stash from all of its keys
"""
stash = _get_stash(backend, stash, passphrase)
try:
click.echo('Purging stash...')
stash.purge(force)
# Maybe we should verify that the list is empty
# afterwards?
cli... | [
"Purge",
"the",
"stash",
"from",
"all",
"of",
"its",
"keys"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1605-L1617 | [
"def",
"purge_stash",
"(",
"force",
",",
"stash",
",",
"passphrase",
",",
"backend",
")",
":",
"stash",
"=",
"_get_stash",
"(",
"backend",
",",
"stash",
",",
"passphrase",
")",
"try",
":",
"click",
".",
"echo",
"(",
"'Purging stash...'",
")",
"stash",
".... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | export_keys | Export all keys to a file | ghost.py | def export_keys(output_path, stash, passphrase, backend):
"""Export all keys to a file
"""
stash = _get_stash(backend, stash, passphrase)
try:
click.echo('Exporting stash to {0}...'.format(output_path))
stash.export(output_path=output_path)
click.echo('Export complete!')
exc... | def export_keys(output_path, stash, passphrase, backend):
"""Export all keys to a file
"""
stash = _get_stash(backend, stash, passphrase)
try:
click.echo('Exporting stash to {0}...'.format(output_path))
stash.export(output_path=output_path)
click.echo('Export complete!')
exc... | [
"Export",
"all",
"keys",
"to",
"a",
"file"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1628-L1638 | [
"def",
"export_keys",
"(",
"output_path",
",",
"stash",
",",
"passphrase",
",",
"backend",
")",
":",
"stash",
"=",
"_get_stash",
"(",
"backend",
",",
"stash",
",",
"passphrase",
")",
"try",
":",
"click",
".",
"echo",
"(",
"'Exporting stash to {0}...'",
".",
... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | load_keys | Load all keys from an exported key file to the stash
`KEY_FILE` is the exported stash file to load keys from | ghost.py | def load_keys(key_file, origin_passphrase, stash, passphrase, backend):
"""Load all keys from an exported key file to the stash
`KEY_FILE` is the exported stash file to load keys from
"""
stash = _get_stash(backend, stash, passphrase)
click.echo('Importing all keys from {0}...'.format(key_file))
... | def load_keys(key_file, origin_passphrase, stash, passphrase, backend):
"""Load all keys from an exported key file to the stash
`KEY_FILE` is the exported stash file to load keys from
"""
stash = _get_stash(backend, stash, passphrase)
click.echo('Importing all keys from {0}...'.format(key_file))
... | [
"Load",
"all",
"keys",
"from",
"an",
"exported",
"key",
"file",
"to",
"the",
"stash"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1648-L1657 | [
"def",
"load_keys",
"(",
"key_file",
",",
"origin_passphrase",
",",
"stash",
",",
"passphrase",
",",
"backend",
")",
":",
"stash",
"=",
"_get_stash",
"(",
"backend",
",",
"stash",
",",
"passphrase",
")",
"click",
".",
"echo",
"(",
"'Importing all keys from {0}... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | migrate_stash | Migrate all keys from a source stash to a destination stash.
`SOURCE_STASH_PATH` and `DESTINATION_STASH_PATH` are the paths
to the stashs you wish to perform the migration on. | ghost.py | def migrate_stash(source_stash_path,
source_passphrase,
source_backend,
destination_stash_path,
destination_passphrase,
destination_backend):
"""Migrate all keys from a source stash to a destination stash.
`SOURCE_STASH_P... | def migrate_stash(source_stash_path,
source_passphrase,
source_backend,
destination_stash_path,
destination_passphrase,
destination_backend):
"""Migrate all keys from a source stash to a destination stash.
`SOURCE_STASH_P... | [
"Migrate",
"all",
"keys",
"from",
"a",
"source",
"stash",
"to",
"a",
"destination",
"stash",
"."
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1682-L1706 | [
"def",
"migrate_stash",
"(",
"source_stash_path",
",",
"source_passphrase",
",",
"source_backend",
",",
"destination_stash_path",
",",
"destination_passphrase",
",",
"destination_backend",
")",
":",
"click",
".",
"echo",
"(",
"'Migrating all keys from {0} to {1}...'",
".",
... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | ssh | Use an ssh type key to connect to a machine via ssh
Note that trying to use a key of the wrong type (e.g. `secret`)
will result in an error.
`KEY_NAME` is the key to use.
For additional information on the different configuration options
for an ssh type key, see the repo's readme. | ghost.py | def ssh(key_name, no_tunnel, stash, passphrase, backend):
"""Use an ssh type key to connect to a machine via ssh
Note that trying to use a key of the wrong type (e.g. `secret`)
will result in an error.
`KEY_NAME` is the key to use.
For additional information on the different configuration options... | def ssh(key_name, no_tunnel, stash, passphrase, backend):
"""Use an ssh type key to connect to a machine via ssh
Note that trying to use a key of the wrong type (e.g. `secret`)
will result in an error.
`KEY_NAME` is the key to use.
For additional information on the different configuration options... | [
"Use",
"an",
"ssh",
"type",
"key",
"to",
"connect",
"to",
"a",
"machine",
"via",
"ssh"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1717-L1769 | [
"def",
"ssh",
"(",
"key_name",
",",
"no_tunnel",
",",
"stash",
",",
"passphrase",
",",
"backend",
")",
":",
"# TODO: find_executable or raise",
"def",
"execute",
"(",
"command",
")",
":",
"try",
":",
"click",
".",
"echo",
"(",
"'Executing: {0}'",
".",
"forma... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | _build_ssh_command | # TODO: Document clearly
IndetityFile="~/.ssh/id_rsa"
ProxyCommand="ssh -i ~/.ssh/id_rsa proxy_IP nc HOST_IP HOST_PORT" | ghost.py | def _build_ssh_command(conn_info, no_tunnel=False):
"""
# TODO: Document clearly
IndetityFile="~/.ssh/id_rsa"
ProxyCommand="ssh -i ~/.ssh/id_rsa proxy_IP nc HOST_IP HOST_PORT"
"""
command = ['ssh', '-i', conn_info['ssh_key_path'], conn_info['conn']]
if conn_info.get('tunnel') and not no_tun... | def _build_ssh_command(conn_info, no_tunnel=False):
"""
# TODO: Document clearly
IndetityFile="~/.ssh/id_rsa"
ProxyCommand="ssh -i ~/.ssh/id_rsa proxy_IP nc HOST_IP HOST_PORT"
"""
command = ['ssh', '-i', conn_info['ssh_key_path'], conn_info['conn']]
if conn_info.get('tunnel') and not no_tun... | [
"#",
"TODO",
":",
"Document",
"clearly",
"IndetityFile",
"=",
"~",
"/",
".",
"ssh",
"/",
"id_rsa",
"ProxyCommand",
"=",
"ssh",
"-",
"i",
"~",
"/",
".",
"ssh",
"/",
"id_rsa",
"proxy_IP",
"nc",
"HOST_IP",
"HOST_PORT"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1787-L1805 | [
"def",
"_build_ssh_command",
"(",
"conn_info",
",",
"no_tunnel",
"=",
"False",
")",
":",
"command",
"=",
"[",
"'ssh'",
",",
"'-i'",
",",
"conn_info",
"[",
"'ssh_key_path'",
"]",
",",
"conn_info",
"[",
"'conn'",
"]",
"]",
"if",
"conn_info",
".",
"get",
"(... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | Stash.put | Put a key inside the stash
if key exists and modify true: delete and create
if key exists and modify false: fail
if key doesn't exist and modify true: fail
if key doesn't exist and modify false: create
`name` is unique and cannot be changed.
`value` must be provided if... | ghost.py | def put(self,
name,
value=None,
modify=False,
metadata=None,
description='',
encrypt=True,
lock=False,
key_type='secret',
add=False):
"""Put a key inside the stash
if key exists and modify true: ... | def put(self,
name,
value=None,
modify=False,
metadata=None,
description='',
encrypt=True,
lock=False,
key_type='secret',
add=False):
"""Put a key inside the stash
if key exists and modify true: ... | [
"Put",
"a",
"key",
"inside",
"the",
"stash"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L222-L318 | [
"def",
"put",
"(",
"self",
",",
"name",
",",
"value",
"=",
"None",
",",
"modify",
"=",
"False",
",",
"metadata",
"=",
"None",
",",
"description",
"=",
"''",
",",
"encrypt",
"=",
"True",
",",
"lock",
"=",
"False",
",",
"key_type",
"=",
"'secret'",
"... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | Stash.get | Return a key with its parameters if it was found. | ghost.py | def get(self, key_name, decrypt=True):
"""Return a key with its parameters if it was found.
"""
self._assert_valid_stash()
key = self._storage.get(key_name).copy()
if not key.get('value'):
return None
if decrypt:
key['value'] = self._decrypt(key['... | def get(self, key_name, decrypt=True):
"""Return a key with its parameters if it was found.
"""
self._assert_valid_stash()
key = self._storage.get(key_name).copy()
if not key.get('value'):
return None
if decrypt:
key['value'] = self._decrypt(key['... | [
"Return",
"a",
"key",
"with",
"its",
"parameters",
"if",
"it",
"was",
"found",
"."
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L343-L359 | [
"def",
"get",
"(",
"self",
",",
"key_name",
",",
"decrypt",
"=",
"True",
")",
":",
"self",
".",
"_assert_valid_stash",
"(",
")",
"key",
"=",
"self",
".",
"_storage",
".",
"get",
"(",
"key_name",
")",
".",
"copy",
"(",
")",
"if",
"not",
"key",
".",
... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | Stash.list | Return a list of all keys. | ghost.py | def list(self,
key_name=None,
max_suggestions=100,
cutoff=0.5,
locked_only=False,
key_type=None):
"""Return a list of all keys.
"""
self._assert_valid_stash()
key_list = [k for k in self._storage.list()
... | def list(self,
key_name=None,
max_suggestions=100,
cutoff=0.5,
locked_only=False,
key_type=None):
"""Return a list of all keys.
"""
self._assert_valid_stash()
key_list = [k for k in self._storage.list()
... | [
"Return",
"a",
"list",
"of",
"all",
"keys",
"."
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L361-L395 | [
"def",
"list",
"(",
"self",
",",
"key_name",
"=",
"None",
",",
"max_suggestions",
"=",
"100",
",",
"cutoff",
"=",
"0.5",
",",
"locked_only",
"=",
"False",
",",
"key_type",
"=",
"None",
")",
":",
"self",
".",
"_assert_valid_stash",
"(",
")",
"key_list",
... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | Stash.delete | Delete a key if it exists. | ghost.py | def delete(self, key_name):
"""Delete a key if it exists.
"""
self._assert_valid_stash()
if key_name == 'stored_passphrase':
raise GhostError(
'`stored_passphrase` is a reserved ghost key name '
'which cannot be deleted')
# TODO: Opti... | def delete(self, key_name):
"""Delete a key if it exists.
"""
self._assert_valid_stash()
if key_name == 'stored_passphrase':
raise GhostError(
'`stored_passphrase` is a reserved ghost key name '
'which cannot be deleted')
# TODO: Opti... | [
"Delete",
"a",
"key",
"if",
"it",
"exists",
"."
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L397-L424 | [
"def",
"delete",
"(",
"self",
",",
"key_name",
")",
":",
"self",
".",
"_assert_valid_stash",
"(",
")",
"if",
"key_name",
"==",
"'stored_passphrase'",
":",
"raise",
"GhostError",
"(",
"'`stored_passphrase` is a reserved ghost key name '",
"'which cannot be deleted'",
")"... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | Stash.purge | Purge the stash from all keys | ghost.py | def purge(self, force=False, key_type=None):
"""Purge the stash from all keys
"""
self._assert_valid_stash()
if not force:
raise GhostError(
"The `force` flag must be provided to perform a stash purge. "
"I mean, you don't really want to just ... | def purge(self, force=False, key_type=None):
"""Purge the stash from all keys
"""
self._assert_valid_stash()
if not force:
raise GhostError(
"The `force` flag must be provided to perform a stash purge. "
"I mean, you don't really want to just ... | [
"Purge",
"the",
"stash",
"from",
"all",
"keys"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L456-L473 | [
"def",
"purge",
"(",
"self",
",",
"force",
"=",
"False",
",",
"key_type",
"=",
"None",
")",
":",
"self",
".",
"_assert_valid_stash",
"(",
")",
"if",
"not",
"force",
":",
"raise",
"GhostError",
"(",
"\"The `force` flag must be provided to perform a stash purge. \""... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | Stash.export | Export all keys in the stash to a list or a file | ghost.py | def export(self, output_path=None, decrypt=False):
"""Export all keys in the stash to a list or a file
"""
self._assert_valid_stash()
all_keys = []
for key in self.list():
# We `dict` this as a precaution as tinydb returns
# a tinydb.database.Element inst... | def export(self, output_path=None, decrypt=False):
"""Export all keys in the stash to a list or a file
"""
self._assert_valid_stash()
all_keys = []
for key in self.list():
# We `dict` this as a precaution as tinydb returns
# a tinydb.database.Element inst... | [
"Export",
"all",
"keys",
"in",
"the",
"stash",
"to",
"a",
"list",
"or",
"a",
"file"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L475-L492 | [
"def",
"export",
"(",
"self",
",",
"output_path",
"=",
"None",
",",
"decrypt",
"=",
"False",
")",
":",
"self",
".",
"_assert_valid_stash",
"(",
")",
"all_keys",
"=",
"[",
"]",
"for",
"key",
"in",
"self",
".",
"list",
"(",
")",
":",
"# We `dict` this as... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | Stash.load | Import keys to the stash from either a list of keys or a file
`keys` is a list of dictionaries created by `self.export`
`stash_path` is a path to a file created by `self.export` | ghost.py | def load(self, origin_passphrase, keys=None, key_file=None):
"""Import keys to the stash from either a list of keys or a file
`keys` is a list of dictionaries created by `self.export`
`stash_path` is a path to a file created by `self.export`
"""
# TODO: Handle keys not dict or k... | def load(self, origin_passphrase, keys=None, key_file=None):
"""Import keys to the stash from either a list of keys or a file
`keys` is a list of dictionaries created by `self.export`
`stash_path` is a path to a file created by `self.export`
"""
# TODO: Handle keys not dict or k... | [
"Import",
"keys",
"to",
"the",
"stash",
"from",
"either",
"a",
"list",
"of",
"keys",
"or",
"a",
"file"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L494-L528 | [
"def",
"load",
"(",
"self",
",",
"origin_passphrase",
",",
"keys",
"=",
"None",
",",
"key_file",
"=",
"None",
")",
":",
"# TODO: Handle keys not dict or key_file not json",
"self",
".",
"_assert_valid_stash",
"(",
")",
"# Check if both or none are provided (ahh, the might... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | Stash._encrypt | Turn a json serializable value into an jsonified, encrypted,
hexa string. | ghost.py | def _encrypt(self, value):
"""Turn a json serializable value into an jsonified, encrypted,
hexa string.
"""
value = json.dumps(value)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
encrypted_value = self.cipher.encrypt(value.encode('utf8')... | def _encrypt(self, value):
"""Turn a json serializable value into an jsonified, encrypted,
hexa string.
"""
value = json.dumps(value)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
encrypted_value = self.cipher.encrypt(value.encode('utf8')... | [
"Turn",
"a",
"json",
"serializable",
"value",
"into",
"an",
"jsonified",
"encrypted",
"hexa",
"string",
"."
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L546-L555 | [
"def",
"_encrypt",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"json",
".",
"dumps",
"(",
"value",
")",
"with",
"warnings",
".",
"catch_warnings",
"(",
")",
":",
"warnings",
".",
"simplefilter",
"(",
"\"ignore\"",
")",
"encrypted_value",
"=",
"sel... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | Stash._decrypt | The exact opposite of _encrypt | ghost.py | def _decrypt(self, hexified_value):
"""The exact opposite of _encrypt
"""
encrypted_value = binascii.unhexlify(hexified_value)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
jsonified_value = self.cipher.decrypt(
encrypted_value).d... | def _decrypt(self, hexified_value):
"""The exact opposite of _encrypt
"""
encrypted_value = binascii.unhexlify(hexified_value)
with warnings.catch_warnings():
warnings.simplefilter("ignore")
jsonified_value = self.cipher.decrypt(
encrypted_value).d... | [
"The",
"exact",
"opposite",
"of",
"_encrypt"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L557-L566 | [
"def",
"_decrypt",
"(",
"self",
",",
"hexified_value",
")",
":",
"encrypted_value",
"=",
"binascii",
".",
"unhexlify",
"(",
"hexified_value",
")",
"with",
"warnings",
".",
"catch_warnings",
"(",
")",
":",
"warnings",
".",
"simplefilter",
"(",
"\"ignore\"",
")"... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | TinyDBStorage.get | Return a dictionary consisting of the key itself
e.g.
{u'created_at': u'2016-10-10 08:31:53',
u'description': None,
u'metadata': None,
u'modified_at': u'2016-10-10 08:31:53',
u'name': u'aws',
u'uid': u'459f12c0-f341-413e-9d7e-7410f912fb74',
u'value'... | ghost.py | def get(self, key_name):
"""Return a dictionary consisting of the key itself
e.g.
{u'created_at': u'2016-10-10 08:31:53',
u'description': None,
u'metadata': None,
u'modified_at': u'2016-10-10 08:31:53',
u'name': u'aws',
u'uid': u'459f12c0-f341-413e-9... | def get(self, key_name):
"""Return a dictionary consisting of the key itself
e.g.
{u'created_at': u'2016-10-10 08:31:53',
u'description': None,
u'metadata': None,
u'modified_at': u'2016-10-10 08:31:53',
u'name': u'aws',
u'uid': u'459f12c0-f341-413e-9... | [
"Return",
"a",
"dictionary",
"consisting",
"of",
"the",
"key",
"itself"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L631-L647 | [
"def",
"get",
"(",
"self",
",",
"key_name",
")",
":",
"result",
"=",
"self",
".",
"db",
".",
"search",
"(",
"Query",
"(",
")",
".",
"name",
"==",
"key_name",
")",
"if",
"not",
"result",
":",
"return",
"{",
"}",
"return",
"result",
"[",
"0",
"]"
] | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | TinyDBStorage.delete | Delete the key and return true if the key was deleted, else false | ghost.py | def delete(self, key_name):
"""Delete the key and return true if the key was deleted, else false
"""
self.db.remove(Query().name == key_name)
return self.get(key_name) == {} | def delete(self, key_name):
"""Delete the key and return true if the key was deleted, else false
"""
self.db.remove(Query().name == key_name)
return self.get(key_name) == {} | [
"Delete",
"the",
"key",
"and",
"return",
"true",
"if",
"the",
"key",
"was",
"deleted",
"else",
"false"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L673-L677 | [
"def",
"delete",
"(",
"self",
",",
"key_name",
")",
":",
"self",
".",
"db",
".",
"remove",
"(",
"Query",
"(",
")",
".",
"name",
"==",
"key_name",
")",
"return",
"self",
".",
"get",
"(",
"key_name",
")",
"==",
"{",
"}"
] | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | SQLAlchemyStorage._construct_key | Return a dictionary representing a key from a list of columns
and a tuple of values | ghost.py | def _construct_key(self, values):
"""Return a dictionary representing a key from a list of columns
and a tuple of values
"""
key = {}
for column, value in zip(self.keys.columns, values):
key.update({column.name: value})
return key | def _construct_key(self, values):
"""Return a dictionary representing a key from a list of columns
and a tuple of values
"""
key = {}
for column, value in zip(self.keys.columns, values):
key.update({column.name: value})
return key | [
"Return",
"a",
"dictionary",
"representing",
"a",
"key",
"from",
"a",
"list",
"of",
"columns",
"and",
"a",
"tuple",
"of",
"values"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L772-L779 | [
"def",
"_construct_key",
"(",
"self",
",",
"values",
")",
":",
"key",
"=",
"{",
"}",
"for",
"column",
",",
"value",
"in",
"zip",
"(",
"self",
".",
"keys",
".",
"columns",
",",
"values",
")",
":",
"key",
".",
"update",
"(",
"{",
"column",
".",
"na... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | ConsulStorage.put | Put and return the only unique identifier possible, its url | ghost.py | def put(self, key):
"""Put and return the only unique identifier possible, its url
"""
self._consul_request('PUT', self._key_url(key['name']), json=key)
return key['name'] | def put(self, key):
"""Put and return the only unique identifier possible, its url
"""
self._consul_request('PUT', self._key_url(key['name']), json=key)
return key['name'] | [
"Put",
"and",
"return",
"the",
"only",
"unique",
"identifier",
"possible",
"its",
"url"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L806-L810 | [
"def",
"put",
"(",
"self",
",",
"key",
")",
":",
"self",
".",
"_consul_request",
"(",
"'PUT'",
",",
"self",
".",
"_key_url",
"(",
"key",
"[",
"'name'",
"]",
")",
",",
"json",
"=",
"key",
")",
"return",
"key",
"[",
"'name'",
"]"
] | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | VaultStorage.put | Put and return the only unique identifier possible, its path | ghost.py | def put(self, key):
"""Put and return the only unique identifier possible, its path
"""
self.client.write(self._key_path(key['name']), **key)
return self._key_path(key['name']) | def put(self, key):
"""Put and return the only unique identifier possible, its path
"""
self.client.write(self._key_path(key['name']), **key)
return self._key_path(key['name']) | [
"Put",
"and",
"return",
"the",
"only",
"unique",
"identifier",
"possible",
"its",
"path"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L878-L882 | [
"def",
"put",
"(",
"self",
",",
"key",
")",
":",
"self",
".",
"client",
".",
"write",
"(",
"self",
".",
"_key_path",
"(",
"key",
"[",
"'name'",
"]",
")",
",",
"*",
"*",
"key",
")",
"return",
"self",
".",
"_key_path",
"(",
"key",
"[",
"'name'",
... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | ElasticsearchStorage.init | Create an Elasticsearch index if necessary | ghost.py | def init(self):
"""Create an Elasticsearch index if necessary
"""
# ignore 400 (IndexAlreadyExistsException) when creating an index
self.es.indices.create(index=self.params['index'], ignore=400) | def init(self):
"""Create an Elasticsearch index if necessary
"""
# ignore 400 (IndexAlreadyExistsException) when creating an index
self.es.indices.create(index=self.params['index'], ignore=400) | [
"Create",
"an",
"Elasticsearch",
"index",
"if",
"necessary"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L942-L946 | [
"def",
"init",
"(",
"self",
")",
":",
"# ignore 400 (IndexAlreadyExistsException) when creating an index",
"self",
".",
"es",
".",
"indices",
".",
"create",
"(",
"index",
"=",
"self",
".",
"params",
"[",
"'index'",
"]",
",",
"ignore",
"=",
"400",
")"
] | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | S3Storage.init | Create a bucket. | ghost.py | def init(self):
"""Create a bucket.
"""
try:
self.client.create_bucket(
Bucket=self.db_path,
CreateBucketConfiguration=self.bucket_configuration)
except botocore.exceptions.ClientError as e:
# If the bucket already exists
... | def init(self):
"""Create a bucket.
"""
try:
self.client.create_bucket(
Bucket=self.db_path,
CreateBucketConfiguration=self.bucket_configuration)
except botocore.exceptions.ClientError as e:
# If the bucket already exists
... | [
"Create",
"a",
"bucket",
"."
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1031-L1042 | [
"def",
"init",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"client",
".",
"create_bucket",
"(",
"Bucket",
"=",
"self",
".",
"db_path",
",",
"CreateBucketConfiguration",
"=",
"self",
".",
"bucket_configuration",
")",
"except",
"botocore",
".",
"exceptions... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | S3Storage.put | Insert the key
:return: Key name | ghost.py | def put(self, key):
"""Insert the key
:return: Key name
"""
self.client.put_object(
Body=json.dumps(key),
Bucket=self.db_path,
Key=key['name'])
return key['name'] | def put(self, key):
"""Insert the key
:return: Key name
"""
self.client.put_object(
Body=json.dumps(key),
Bucket=self.db_path,
Key=key['name'])
return key['name'] | [
"Insert",
"the",
"key",
":",
"return",
":",
"Key",
"name"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1044-L1052 | [
"def",
"put",
"(",
"self",
",",
"key",
")",
":",
"self",
".",
"client",
".",
"put_object",
"(",
"Body",
"=",
"json",
".",
"dumps",
"(",
"key",
")",
",",
"Bucket",
"=",
"self",
".",
"db_path",
",",
"Key",
"=",
"key",
"[",
"'name'",
"]",
")",
"re... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | S3Storage.list | Lists the keys
:return: Returns a list of all keys (not just key names, but rather
the keys themselves). | ghost.py | def list(self):
"""Lists the keys
:return: Returns a list of all keys (not just key names, but rather
the keys themselves).
"""
response = self.client.list_objects_v2(Bucket=self.db_path)
if u'Contents' in response:
# Filter out everything but the key names
... | def list(self):
"""Lists the keys
:return: Returns a list of all keys (not just key names, but rather
the keys themselves).
"""
response = self.client.list_objects_v2(Bucket=self.db_path)
if u'Contents' in response:
# Filter out everything but the key names
... | [
"Lists",
"the",
"keys",
":",
"return",
":",
"Returns",
"a",
"list",
"of",
"all",
"keys",
"(",
"not",
"just",
"key",
"names",
"but",
"rather",
"the",
"keys",
"themselves",
")",
"."
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1054-L1070 | [
"def",
"list",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"list_objects_v2",
"(",
"Bucket",
"=",
"self",
".",
"db_path",
")",
"if",
"u'Contents'",
"in",
"response",
":",
"# Filter out everything but the key names",
"keys",
"=",
"[",
... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | S3Storage.get | Gets the key.
:return: The key itself in a dictionary | ghost.py | def get(self, key_name):
"""Gets the key.
:return: The key itself in a dictionary
"""
try:
obj = self.client.get_object(
Bucket=self.db_path,
Key=key_name)['Body'].read().decode("utf-8")
return json.loads(obj)
except botoco... | def get(self, key_name):
"""Gets the key.
:return: The key itself in a dictionary
"""
try:
obj = self.client.get_object(
Bucket=self.db_path,
Key=key_name)['Body'].read().decode("utf-8")
return json.loads(obj)
except botoco... | [
"Gets",
"the",
"key",
".",
":",
"return",
":",
"The",
"key",
"itself",
"in",
"a",
"dictionary"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1072-L1085 | [
"def",
"get",
"(",
"self",
",",
"key_name",
")",
":",
"try",
":",
"obj",
"=",
"self",
".",
"client",
".",
"get_object",
"(",
"Bucket",
"=",
"self",
".",
"db_path",
",",
"Key",
"=",
"key_name",
")",
"[",
"'Body'",
"]",
".",
"read",
"(",
")",
".",
... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | S3Storage.delete | Delete the key.
:return: True if it was deleted, False otherwise | ghost.py | def delete(self, key_name):
"""Delete the key.
:return: True if it was deleted, False otherwise
"""
self.client.delete_object(
Bucket=self.db_path,
Key=key_name)
return self.get(key_name) == {} | def delete(self, key_name):
"""Delete the key.
:return: True if it was deleted, False otherwise
"""
self.client.delete_object(
Bucket=self.db_path,
Key=key_name)
return self.get(key_name) == {} | [
"Delete",
"the",
"key",
".",
":",
"return",
":",
"True",
"if",
"it",
"was",
"deleted",
"False",
"otherwise"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1087-L1095 | [
"def",
"delete",
"(",
"self",
",",
"key_name",
")",
":",
"self",
".",
"client",
".",
"delete_object",
"(",
"Bucket",
"=",
"self",
".",
"db_path",
",",
"Key",
"=",
"key_name",
")",
"return",
"self",
".",
"get",
"(",
"key_name",
")",
"==",
"{",
"}"
] | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | S3Storage.is_initialized | Check if bucket exists.
:return: True if initialized, False otherwise | ghost.py | def is_initialized(self):
"""Check if bucket exists.
:return: True if initialized, False otherwise
"""
try:
return self.client.head_bucket(
Bucket=self.db_path)['ResponseMetadata']['HTTPStatusCode'] \
== 200
except botocore.exception... | def is_initialized(self):
"""Check if bucket exists.
:return: True if initialized, False otherwise
"""
try:
return self.client.head_bucket(
Bucket=self.db_path)['ResponseMetadata']['HTTPStatusCode'] \
== 200
except botocore.exception... | [
"Check",
"if",
"bucket",
"exists",
".",
":",
"return",
":",
"True",
"if",
"initialized",
"False",
"otherwise"
] | nir0s/ghost | python | https://github.com/nir0s/ghost/blob/77da967a4577ca4cf100cfe34e87b39ad88bf21c/ghost.py#L1098-L1111 | [
"def",
"is_initialized",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"client",
".",
"head_bucket",
"(",
"Bucket",
"=",
"self",
".",
"db_path",
")",
"[",
"'ResponseMetadata'",
"]",
"[",
"'HTTPStatusCode'",
"]",
"==",
"200",
"except",
"botocore... | 77da967a4577ca4cf100cfe34e87b39ad88bf21c |
valid | terminal | Launch minterm from pyserial | nodemcu_uploader/term.py | def terminal(port=default_port(), baud='9600'):
"""Launch minterm from pyserial"""
testargs = ['nodemcu-uploader', port, baud]
# TODO: modifying argv is no good
sys.argv = testargs
# resuse miniterm on main function
miniterm.main() | def terminal(port=default_port(), baud='9600'):
"""Launch minterm from pyserial"""
testargs = ['nodemcu-uploader', port, baud]
# TODO: modifying argv is no good
sys.argv = testargs
# resuse miniterm on main function
miniterm.main() | [
"Launch",
"minterm",
"from",
"pyserial"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/term.py#L9-L15 | [
"def",
"terminal",
"(",
"port",
"=",
"default_port",
"(",
")",
",",
"baud",
"=",
"'9600'",
")",
":",
"testargs",
"=",
"[",
"'nodemcu-uploader'",
",",
"port",
",",
"baud",
"]",
"# TODO: modifying argv is no good",
"sys",
".",
"argv",
"=",
"testargs",
"# resus... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.__set_baudrate | setting baudrate if supported | nodemcu_uploader/uploader.py | def __set_baudrate(self, baud):
"""setting baudrate if supported"""
log.info('Changing communication to %s baud', baud)
self.__writeln(UART_SETUP.format(baud=baud))
# Wait for the string to be sent before switching baud
time.sleep(0.1)
try:
self._port.setBaudr... | def __set_baudrate(self, baud):
"""setting baudrate if supported"""
log.info('Changing communication to %s baud', baud)
self.__writeln(UART_SETUP.format(baud=baud))
# Wait for the string to be sent before switching baud
time.sleep(0.1)
try:
self._port.setBaudr... | [
"setting",
"baudrate",
"if",
"supported"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L91-L101 | [
"def",
"__set_baudrate",
"(",
"self",
",",
"baud",
")",
":",
"log",
".",
"info",
"(",
"'Changing communication to %s baud'",
",",
"baud",
")",
"self",
".",
"__writeln",
"(",
"UART_SETUP",
".",
"format",
"(",
"baud",
"=",
"baud",
")",
")",
"# Wait for the str... | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.set_timeout | Set the timeout for the communication with the device. | nodemcu_uploader/uploader.py | def set_timeout(self, timeout):
"""Set the timeout for the communication with the device."""
timeout = int(timeout) # will raise on Error
self._timeout = timeout == 0 and 999999 or timeout | def set_timeout(self, timeout):
"""Set the timeout for the communication with the device."""
timeout = int(timeout) # will raise on Error
self._timeout = timeout == 0 and 999999 or timeout | [
"Set",
"the",
"timeout",
"for",
"the",
"communication",
"with",
"the",
"device",
"."
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L104-L107 | [
"def",
"set_timeout",
"(",
"self",
",",
"timeout",
")",
":",
"timeout",
"=",
"int",
"(",
"timeout",
")",
"# will raise on Error",
"self",
".",
"_timeout",
"=",
"timeout",
"==",
"0",
"and",
"999999",
"or",
"timeout"
] | 557a25f37b1fb4e31a745719e237e42fff192834 |
valid | Uploader.__clear_buffers | Clears the input and output buffers | nodemcu_uploader/uploader.py | def __clear_buffers(self):
"""Clears the input and output buffers"""
try:
self._port.reset_input_buffer()
self._port.reset_output_buffer()
except AttributeError:
#pySerial 2.7
self._port.flushInput()
self._port.flushOutput() | def __clear_buffers(self):
"""Clears the input and output buffers"""
try:
self._port.reset_input_buffer()
self._port.reset_output_buffer()
except AttributeError:
#pySerial 2.7
self._port.flushInput()
self._port.flushOutput() | [
"Clears",
"the",
"input",
"and",
"output",
"buffers"
] | kmpm/nodemcu-uploader | python | https://github.com/kmpm/nodemcu-uploader/blob/557a25f37b1fb4e31a745719e237e42fff192834/nodemcu_uploader/uploader.py#L110-L118 | [
"def",
"__clear_buffers",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_port",
".",
"reset_input_buffer",
"(",
")",
"self",
".",
"_port",
".",
"reset_output_buffer",
"(",
")",
"except",
"AttributeError",
":",
"#pySerial 2.7",
"self",
".",
"_port",
".",
... | 557a25f37b1fb4e31a745719e237e42fff192834 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.