repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
reanahub/reana-commons
reana_commons/utils.py
calculate_job_input_hash
def calculate_job_input_hash(job_spec, workflow_json): """Calculate md5 hash of job specification and workflow json.""" if 'workflow_workspace' in job_spec: del job_spec['workflow_workspace'] job_md5_buffer = md5() job_md5_buffer.update(json.dumps(job_spec).encode('utf-8')) job_md5_buffer.up...
python
def calculate_job_input_hash(job_spec, workflow_json): """Calculate md5 hash of job specification and workflow json.""" if 'workflow_workspace' in job_spec: del job_spec['workflow_workspace'] job_md5_buffer = md5() job_md5_buffer.update(json.dumps(job_spec).encode('utf-8')) job_md5_buffer.up...
[ "def", "calculate_job_input_hash", "(", "job_spec", ",", "workflow_json", ")", ":", "if", "'workflow_workspace'", "in", "job_spec", ":", "del", "job_spec", "[", "'workflow_workspace'", "]", "job_md5_buffer", "=", "md5", "(", ")", "job_md5_buffer", ".", "update", "...
Calculate md5 hash of job specification and workflow json.
[ "Calculate", "md5", "hash", "of", "job", "specification", "and", "workflow", "json", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/utils.py#L78-L85
reanahub/reana-commons
reana_commons/utils.py
calculate_file_access_time
def calculate_file_access_time(workflow_workspace): """Calculate access times of files in workspace.""" access_times = {} for subdir, dirs, files in os.walk(workflow_workspace): for file in files: file_path = os.path.join(subdir, file) access_times[file_path] = os.stat(file_p...
python
def calculate_file_access_time(workflow_workspace): """Calculate access times of files in workspace.""" access_times = {} for subdir, dirs, files in os.walk(workflow_workspace): for file in files: file_path = os.path.join(subdir, file) access_times[file_path] = os.stat(file_p...
[ "def", "calculate_file_access_time", "(", "workflow_workspace", ")", ":", "access_times", "=", "{", "}", "for", "subdir", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "workflow_workspace", ")", ":", "for", "file", "in", "files", ":", "file_path",...
Calculate access times of files in workspace.
[ "Calculate", "access", "times", "of", "files", "in", "workspace", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/utils.py#L88-L95
reanahub/reana-commons
reana_commons/utils.py
copy_openapi_specs
def copy_openapi_specs(output_path, component): """Copy generated and validated openapi specs to reana-commons module.""" if component == 'reana-server': file = 'reana_server.json' elif component == 'reana-workflow-controller': file = 'reana_workflow_controller.json' elif component == 'r...
python
def copy_openapi_specs(output_path, component): """Copy generated and validated openapi specs to reana-commons module.""" if component == 'reana-server': file = 'reana_server.json' elif component == 'reana-workflow-controller': file = 'reana_workflow_controller.json' elif component == 'r...
[ "def", "copy_openapi_specs", "(", "output_path", ",", "component", ")", ":", "if", "component", "==", "'reana-server'", ":", "file", "=", "'reana_server.json'", "elif", "component", "==", "'reana-workflow-controller'", ":", "file", "=", "'reana_workflow_controller.json'...
Copy generated and validated openapi specs to reana-commons module.
[ "Copy", "generated", "and", "validated", "openapi", "specs", "to", "reana", "-", "commons", "module", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/utils.py#L98-L126
reanahub/reana-commons
reana_commons/utils.py
get_workflow_status_change_verb
def get_workflow_status_change_verb(status): """Give the correct verb conjugation depending on status tense. :param status: String which represents the status the workflow changed to. """ verb = '' if status.endswith('ing'): verb = 'is' elif status.endswith('ed'): verb = 'has be...
python
def get_workflow_status_change_verb(status): """Give the correct verb conjugation depending on status tense. :param status: String which represents the status the workflow changed to. """ verb = '' if status.endswith('ing'): verb = 'is' elif status.endswith('ed'): verb = 'has be...
[ "def", "get_workflow_status_change_verb", "(", "status", ")", ":", "verb", "=", "''", "if", "status", ".", "endswith", "(", "'ing'", ")", ":", "verb", "=", "'is'", "elif", "status", ".", "endswith", "(", "'ed'", ")", ":", "verb", "=", "'has been'", "else...
Give the correct verb conjugation depending on status tense. :param status: String which represents the status the workflow changed to.
[ "Give", "the", "correct", "verb", "conjugation", "depending", "on", "status", "tense", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/utils.py#L129-L142
reanahub/reana-commons
reana_commons/utils.py
build_progress_message
def build_progress_message(total=None, running=None, finished=None, failed=None, cached=None): """Build the progress message with correct formatting.""" progress_message = {} if total: progres...
python
def build_progress_message(total=None, running=None, finished=None, failed=None, cached=None): """Build the progress message with correct formatting.""" progress_message = {} if total: progres...
[ "def", "build_progress_message", "(", "total", "=", "None", ",", "running", "=", "None", ",", "finished", "=", "None", ",", "failed", "=", "None", ",", "cached", "=", "None", ")", ":", "progress_message", "=", "{", "}", "if", "total", ":", "progress_mess...
Build the progress message with correct formatting.
[ "Build", "the", "progress", "message", "with", "correct", "formatting", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/utils.py#L145-L162
reanahub/reana-commons
reana_commons/utils.py
build_caching_info_message
def build_caching_info_message(job_spec, job_id, workflow_workspace, workflow_json, result_path): """Build the caching info message with correct formatting.""" caching_info_message = { ...
python
def build_caching_info_message(job_spec, job_id, workflow_workspace, workflow_json, result_path): """Build the caching info message with correct formatting.""" caching_info_message = { ...
[ "def", "build_caching_info_message", "(", "job_spec", ",", "job_id", ",", "workflow_workspace", ",", "workflow_json", ",", "result_path", ")", ":", "caching_info_message", "=", "{", "\"job_spec\"", ":", "job_spec", ",", "\"job_id\"", ":", "job_id", ",", "\"workflow_...
Build the caching info message with correct formatting.
[ "Build", "the", "caching", "info", "message", "with", "correct", "formatting", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/utils.py#L165-L178
reanahub/reana-commons
reana_commons/utils.py
get_workspace_disk_usage
def get_workspace_disk_usage(workspace, summarize=False): """Retrieve disk usage information of a workspace.""" command = ['du', '-h'] if summarize: command.append('-s') else: command.append('-a') command.append(workspace) disk_usage_info = subprocess.check_output(command).decode...
python
def get_workspace_disk_usage(workspace, summarize=False): """Retrieve disk usage information of a workspace.""" command = ['du', '-h'] if summarize: command.append('-s') else: command.append('-a') command.append(workspace) disk_usage_info = subprocess.check_output(command).decode...
[ "def", "get_workspace_disk_usage", "(", "workspace", ",", "summarize", "=", "False", ")", ":", "command", "=", "[", "'du'", ",", "'-h'", "]", "if", "summarize", ":", "command", ".", "append", "(", "'-s'", ")", "else", ":", "command", ".", "append", "(", ...
Retrieve disk usage information of a workspace.
[ "Retrieve", "disk", "usage", "information", "of", "a", "workspace", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/utils.py#L181-L198
reanahub/reana-commons
reana_commons/utils.py
render_cvmfs_pvc
def render_cvmfs_pvc(cvmfs_volume): """Render REANA_CVMFS_PVC_TEMPLATE.""" name = CVMFS_REPOSITORIES[cvmfs_volume] rendered_template = dict(REANA_CVMFS_PVC_TEMPLATE) rendered_template['metadata']['name'] = 'csi-cvmfs-{}-pvc'.format(name) rendered_template['spec']['storageClassName'] = "csi-cvmfs-{}"...
python
def render_cvmfs_pvc(cvmfs_volume): """Render REANA_CVMFS_PVC_TEMPLATE.""" name = CVMFS_REPOSITORIES[cvmfs_volume] rendered_template = dict(REANA_CVMFS_PVC_TEMPLATE) rendered_template['metadata']['name'] = 'csi-cvmfs-{}-pvc'.format(name) rendered_template['spec']['storageClassName'] = "csi-cvmfs-{}"...
[ "def", "render_cvmfs_pvc", "(", "cvmfs_volume", ")", ":", "name", "=", "CVMFS_REPOSITORIES", "[", "cvmfs_volume", "]", "rendered_template", "=", "dict", "(", "REANA_CVMFS_PVC_TEMPLATE", ")", "rendered_template", "[", "'metadata'", "]", "[", "'name'", "]", "=", "'c...
Render REANA_CVMFS_PVC_TEMPLATE.
[ "Render", "REANA_CVMFS_PVC_TEMPLATE", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/utils.py#L201-L207
reanahub/reana-commons
reana_commons/utils.py
render_cvmfs_sc
def render_cvmfs_sc(cvmfs_volume): """Render REANA_CVMFS_SC_TEMPLATE.""" name = CVMFS_REPOSITORIES[cvmfs_volume] rendered_template = dict(REANA_CVMFS_SC_TEMPLATE) rendered_template['metadata']['name'] = "csi-cvmfs-{}".format(name) rendered_template['parameters']['repository'] = cvmfs_volume retu...
python
def render_cvmfs_sc(cvmfs_volume): """Render REANA_CVMFS_SC_TEMPLATE.""" name = CVMFS_REPOSITORIES[cvmfs_volume] rendered_template = dict(REANA_CVMFS_SC_TEMPLATE) rendered_template['metadata']['name'] = "csi-cvmfs-{}".format(name) rendered_template['parameters']['repository'] = cvmfs_volume retu...
[ "def", "render_cvmfs_sc", "(", "cvmfs_volume", ")", ":", "name", "=", "CVMFS_REPOSITORIES", "[", "cvmfs_volume", "]", "rendered_template", "=", "dict", "(", "REANA_CVMFS_SC_TEMPLATE", ")", "rendered_template", "[", "'metadata'", "]", "[", "'name'", "]", "=", "\"cs...
Render REANA_CVMFS_SC_TEMPLATE.
[ "Render", "REANA_CVMFS_SC_TEMPLATE", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/utils.py#L210-L216
reanahub/reana-commons
reana_commons/utils.py
create_cvmfs_storage_class
def create_cvmfs_storage_class(cvmfs_volume): """Create CVMFS storage class.""" from kubernetes.client.rest import ApiException from reana_commons.k8s.api_client import current_k8s_storagev1_api_client try: current_k8s_storagev1_api_client.\ create_storage_class( ren...
python
def create_cvmfs_storage_class(cvmfs_volume): """Create CVMFS storage class.""" from kubernetes.client.rest import ApiException from reana_commons.k8s.api_client import current_k8s_storagev1_api_client try: current_k8s_storagev1_api_client.\ create_storage_class( ren...
[ "def", "create_cvmfs_storage_class", "(", "cvmfs_volume", ")", ":", "from", "kubernetes", ".", "client", ".", "rest", "import", "ApiException", "from", "reana_commons", ".", "k8s", ".", "api_client", "import", "current_k8s_storagev1_api_client", "try", ":", "current_k...
Create CVMFS storage class.
[ "Create", "CVMFS", "storage", "class", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/utils.py#L219-L231
reanahub/reana-commons
reana_commons/utils.py
create_cvmfs_persistent_volume_claim
def create_cvmfs_persistent_volume_claim(cvmfs_volume): """Create CVMFS persistent volume claim.""" from kubernetes.client.rest import ApiException from reana_commons.k8s.api_client import current_k8s_corev1_api_client try: current_k8s_corev1_api_client.\ create_namespaced_persisten...
python
def create_cvmfs_persistent_volume_claim(cvmfs_volume): """Create CVMFS persistent volume claim.""" from kubernetes.client.rest import ApiException from reana_commons.k8s.api_client import current_k8s_corev1_api_client try: current_k8s_corev1_api_client.\ create_namespaced_persisten...
[ "def", "create_cvmfs_persistent_volume_claim", "(", "cvmfs_volume", ")", ":", "from", "kubernetes", ".", "client", ".", "rest", "import", "ApiException", "from", "reana_commons", ".", "k8s", ".", "api_client", "import", "current_k8s_corev1_api_client", "try", ":", "cu...
Create CVMFS persistent volume claim.
[ "Create", "CVMFS", "persistent", "volume", "claim", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/utils.py#L234-L247
reanahub/reana-commons
reana_commons/k8s/api_client.py
create_api_client
def create_api_client(api='BatchV1'): """Create Kubernetes API client using config. :param api: String which represents which Kubernetes API to spawn. By default BatchV1. :returns: Kubernetes python client object for a specific API i.e. BatchV1. """ k8s_config.load_incluster_config() ap...
python
def create_api_client(api='BatchV1'): """Create Kubernetes API client using config. :param api: String which represents which Kubernetes API to spawn. By default BatchV1. :returns: Kubernetes python client object for a specific API i.e. BatchV1. """ k8s_config.load_incluster_config() ap...
[ "def", "create_api_client", "(", "api", "=", "'BatchV1'", ")", ":", "k8s_config", ".", "load_incluster_config", "(", ")", "api_configuration", "=", "client", ".", "Configuration", "(", ")", "api_configuration", ".", "verify_ssl", "=", "False", "if", "api", "==",...
Create Kubernetes API client using config. :param api: String which represents which Kubernetes API to spawn. By default BatchV1. :returns: Kubernetes python client object for a specific API i.e. BatchV1.
[ "Create", "Kubernetes", "API", "client", "using", "config", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/k8s/api_client.py#L18-L36
reanahub/reana-commons
reana_commons/publisher.py
BasePublisher.__error_callback
def __error_callback(self, exception, interval): """Execute when there is an error while sending a message. :param exception: Exception which has been thrown while trying to send the message. :param interval: Interval in which the message delivery will be retried. ...
python
def __error_callback(self, exception, interval): """Execute when there is an error while sending a message. :param exception: Exception which has been thrown while trying to send the message. :param interval: Interval in which the message delivery will be retried. ...
[ "def", "__error_callback", "(", "self", ",", "exception", ",", "interval", ")", ":", "logging", ".", "error", "(", "'Error while publishing {}'", ".", "format", "(", "exception", ")", ")", "logging", ".", "info", "(", "'Retry in %s seconds.'", ",", "interval", ...
Execute when there is an error while sending a message. :param exception: Exception which has been thrown while trying to send the message. :param interval: Interval in which the message delivery will be retried.
[ "Execute", "when", "there", "is", "an", "error", "while", "sending", "a", "message", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/publisher.py#L53-L63
reanahub/reana-commons
reana_commons/publisher.py
BasePublisher._publish
def _publish(self, msg): """Publish, handling retries, a message in the queue. :param msg: Object which represents the message to be sent in the queue. Note that this object should be serializable in the configured format (by default JSON). """ connection = self....
python
def _publish(self, msg): """Publish, handling retries, a message in the queue. :param msg: Object which represents the message to be sent in the queue. Note that this object should be serializable in the configured format (by default JSON). """ connection = self....
[ "def", "_publish", "(", "self", ",", "msg", ")", ":", "connection", "=", "self", ".", "_connection", ".", "clone", "(", ")", "publish", "=", "connection", ".", "ensure", "(", "self", ".", "producer", ",", "self", ".", "producer", ".", "publish", ",", ...
Publish, handling retries, a message in the queue. :param msg: Object which represents the message to be sent in the queue. Note that this object should be serializable in the configured format (by default JSON).
[ "Publish", "handling", "retries", "a", "message", "in", "the", "queue", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/publisher.py#L65-L78
reanahub/reana-commons
reana_commons/publisher.py
WorkflowStatusPublisher.publish_workflow_status
def publish_workflow_status(self, workflow_uuid, status, logs='', message=None): """Publish workflow status using the configured. :param workflow_uudid: String which represents the workflow UUID. :param status: Integer which represents the status of the workflow,...
python
def publish_workflow_status(self, workflow_uuid, status, logs='', message=None): """Publish workflow status using the configured. :param workflow_uudid: String which represents the workflow UUID. :param status: Integer which represents the status of the workflow,...
[ "def", "publish_workflow_status", "(", "self", ",", "workflow_uuid", ",", "status", ",", "logs", "=", "''", ",", "message", "=", "None", ")", ":", "msg", "=", "{", "\"workflow_uuid\"", ":", "workflow_uuid", ",", "\"logs\"", ":", "logs", ",", "\"status\"", ...
Publish workflow status using the configured. :param workflow_uudid: String which represents the workflow UUID. :param status: Integer which represents the status of the workflow, this is defined in the `reana-db` `Workflow` models. :param logs: String which represents the logs whic...
[ "Publish", "workflow", "status", "using", "the", "configured", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/publisher.py#L100-L118
reanahub/reana-commons
reana_commons/publisher.py
WorkflowSubmissionPublisher.publish_workflow_submission
def publish_workflow_submission(self, user_id, workflow_id_or_name, parameters): """Publish workflow submission parameters.""" msg = { "user": user_id, "workflow_id_or_name...
python
def publish_workflow_submission(self, user_id, workflow_id_or_name, parameters): """Publish workflow submission parameters.""" msg = { "user": user_id, "workflow_id_or_name...
[ "def", "publish_workflow_submission", "(", "self", ",", "user_id", ",", "workflow_id_or_name", ",", "parameters", ")", ":", "msg", "=", "{", "\"user\"", ":", "user_id", ",", "\"workflow_id_or_name\"", ":", "workflow_id_or_name", ",", "\"parameters\"", ":", "paramete...
Publish workflow submission parameters.
[ "Publish", "workflow", "submission", "parameters", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/publisher.py#L133-L143
reanahub/reana-commons
reana_commons/serial.py
serial_load
def serial_load(workflow_file, specification, parameters=None, original=None): """Validate and return a expanded REANA Serial workflow specification. :param workflow_file: A specification file compliant with REANA Serial workflow specification. :returns: A dictionary which represents the valid Seri...
python
def serial_load(workflow_file, specification, parameters=None, original=None): """Validate and return a expanded REANA Serial workflow specification. :param workflow_file: A specification file compliant with REANA Serial workflow specification. :returns: A dictionary which represents the valid Seri...
[ "def", "serial_load", "(", "workflow_file", ",", "specification", ",", "parameters", "=", "None", ",", "original", "=", "None", ")", ":", "parameters", "=", "parameters", "or", "{", "}", "if", "not", "specification", ":", "with", "open", "(", "workflow_file"...
Validate and return a expanded REANA Serial workflow specification. :param workflow_file: A specification file compliant with REANA Serial workflow specification. :returns: A dictionary which represents the valid Serial workflow with all parameters expanded.
[ "Validate", "and", "return", "a", "expanded", "REANA", "Serial", "workflow", "specification", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/serial.py#L55-L75
reanahub/reana-commons
reana_commons/serial.py
_expand_parameters
def _expand_parameters(specification, parameters, original=None): """Expand parameters inside comands for Serial workflow specifications. :param specification: Full valid Serial workflow specification. :param parameters: Parameters to be extended on a Serial specification. :param original: Flag which, ...
python
def _expand_parameters(specification, parameters, original=None): """Expand parameters inside comands for Serial workflow specifications. :param specification: Full valid Serial workflow specification. :param parameters: Parameters to be extended on a Serial specification. :param original: Flag which, ...
[ "def", "_expand_parameters", "(", "specification", ",", "parameters", ",", "original", "=", "None", ")", ":", "expanded_specification", "=", "deepcopy", "(", "specification", ")", "try", ":", "for", "step_num", ",", "step", "in", "enumerate", "(", "expanded_spec...
Expand parameters inside comands for Serial workflow specifications. :param specification: Full valid Serial workflow specification. :param parameters: Parameters to be extended on a Serial specification. :param original: Flag which, determins type of specifications to return. :returns: If 'original' p...
[ "Expand", "parameters", "inside", "comands", "for", "Serial", "workflow", "specifications", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/serial.py#L78-L108
reanahub/reana-commons
reana_commons/tasks.py
reana_ready
def reana_ready(): """Check if reana can start new workflows.""" from reana_commons.config import REANA_READY_CONDITIONS for module_name, condition_list in REANA_READY_CONDITIONS.items(): for condition_name in condition_list: module = importlib.import_module(module_name) cond...
python
def reana_ready(): """Check if reana can start new workflows.""" from reana_commons.config import REANA_READY_CONDITIONS for module_name, condition_list in REANA_READY_CONDITIONS.items(): for condition_name in condition_list: module = importlib.import_module(module_name) cond...
[ "def", "reana_ready", "(", ")", ":", "from", "reana_commons", ".", "config", "import", "REANA_READY_CONDITIONS", "for", "module_name", ",", "condition_list", "in", "REANA_READY_CONDITIONS", ".", "items", "(", ")", ":", "for", "condition_name", "in", "condition_list"...
Check if reana can start new workflows.
[ "Check", "if", "reana", "can", "start", "new", "workflows", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/tasks.py#L24-L33
reanahub/reana-commons
reana_commons/tasks.py
check_predefined_conditions
def check_predefined_conditions(): """Check k8s predefined conditions for the nodes.""" try: node_info = current_k8s_corev1_api_client.list_node() for node in node_info.items: # check based on the predefined conditions about the # node status: MemoryPressure, OutOfDisk, K...
python
def check_predefined_conditions(): """Check k8s predefined conditions for the nodes.""" try: node_info = current_k8s_corev1_api_client.list_node() for node in node_info.items: # check based on the predefined conditions about the # node status: MemoryPressure, OutOfDisk, K...
[ "def", "check_predefined_conditions", "(", ")", ":", "try", ":", "node_info", "=", "current_k8s_corev1_api_client", ".", "list_node", "(", ")", "for", "node", "in", "node_info", ".", "items", ":", "# check based on the predefined conditions about the", "# node status: Mem...
Check k8s predefined conditions for the nodes.
[ "Check", "k8s", "predefined", "conditions", "for", "the", "nodes", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/tasks.py#L36-L51
reanahub/reana-commons
reana_commons/tasks.py
check_running_job_count
def check_running_job_count(): """Check upper limit on running jobs.""" try: job_list = current_k8s_batchv1_api_client.\ list_job_for_all_namespaces() if len(job_list.items) > K8S_MAXIMUM_CONCURRENT_JOBS: return False except ApiException as e: log.error('Somet...
python
def check_running_job_count(): """Check upper limit on running jobs.""" try: job_list = current_k8s_batchv1_api_client.\ list_job_for_all_namespaces() if len(job_list.items) > K8S_MAXIMUM_CONCURRENT_JOBS: return False except ApiException as e: log.error('Somet...
[ "def", "check_running_job_count", "(", ")", ":", "try", ":", "job_list", "=", "current_k8s_batchv1_api_client", ".", "list_job_for_all_namespaces", "(", ")", "if", "len", "(", "job_list", ".", "items", ")", ">", "K8S_MAXIMUM_CONCURRENT_JOBS", ":", "return", "False",...
Check upper limit on running jobs.
[ "Check", "upper", "limit", "on", "running", "jobs", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/tasks.py#L54-L65
reanahub/reana-commons
reana_commons/api_client.py
BaseAPIClient._get_spec
def _get_spec(self, spec_file): """Get json specification from package data.""" spec_file_path = os.path.join( pkg_resources. resource_filename( 'reana_commons', 'openapi_specifications'), spec_file) with open(spec_file_path) a...
python
def _get_spec(self, spec_file): """Get json specification from package data.""" spec_file_path = os.path.join( pkg_resources. resource_filename( 'reana_commons', 'openapi_specifications'), spec_file) with open(spec_file_path) a...
[ "def", "_get_spec", "(", "self", ",", "spec_file", ")", ":", "spec_file_path", "=", "os", ".", "path", ".", "join", "(", "pkg_resources", ".", "resource_filename", "(", "'reana_commons'", ",", "'openapi_specifications'", ")", ",", "spec_file", ")", "with", "op...
Get json specification from package data.
[ "Get", "json", "specification", "from", "package", "data", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/api_client.py#L46-L57
reanahub/reana-commons
reana_commons/api_client.py
JobControllerAPIClient.submit
def submit(self, workflow_uuid='', experiment='', image='', cmd='', prettified_cmd='', workflow_workspace='', job_name='', cvmfs_mounts='false'): """Submit a job to RJC API. :param na...
python
def submit(self, workflow_uuid='', experiment='', image='', cmd='', prettified_cmd='', workflow_workspace='', job_name='', cvmfs_mounts='false'): """Submit a job to RJC API. :param na...
[ "def", "submit", "(", "self", ",", "workflow_uuid", "=", "''", ",", "experiment", "=", "''", ",", "image", "=", "''", ",", "cmd", "=", "''", ",", "prettified_cmd", "=", "''", ",", "workflow_workspace", "=", "''", ",", "job_name", "=", "''", ",", "cvm...
Submit a job to RJC API. :param name: Name of the job. :param experiment: Experiment the job belongs to. :param image: Identifier of the Docker image which will run the job. :param cmd: String which represents the command to execute. It can be modified by the workflow engine...
[ "Submit", "a", "job", "to", "RJC", "API", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/api_client.py#L63-L104
reanahub/reana-commons
reana_commons/api_client.py
JobControllerAPIClient.check_status
def check_status(self, job_id): """Check status of a job.""" response, http_response = self._client.jobs.get_job(job_id=job_id).\ result() if http_response.status_code == 404: raise HTTPNotFound('The given job ID was not found. Error: {}'. f...
python
def check_status(self, job_id): """Check status of a job.""" response, http_response = self._client.jobs.get_job(job_id=job_id).\ result() if http_response.status_code == 404: raise HTTPNotFound('The given job ID was not found. Error: {}'. f...
[ "def", "check_status", "(", "self", ",", "job_id", ")", ":", "response", ",", "http_response", "=", "self", ".", "_client", ".", "jobs", ".", "get_job", "(", "job_id", "=", "job_id", ")", ".", "result", "(", ")", "if", "http_response", ".", "status_code"...
Check status of a job.
[ "Check", "status", "of", "a", "job", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/api_client.py#L106-L113
reanahub/reana-commons
reana_commons/api_client.py
JobControllerAPIClient.get_logs
def get_logs(self, job_id): """Get logs of a job.""" response, http_response = self._client.jobs.get_logs(job_id=job_id).\ result() if http_response.status_code == 404: raise HTTPNotFound('The given job ID was not found. Error: {}'. format(h...
python
def get_logs(self, job_id): """Get logs of a job.""" response, http_response = self._client.jobs.get_logs(job_id=job_id).\ result() if http_response.status_code == 404: raise HTTPNotFound('The given job ID was not found. Error: {}'. format(h...
[ "def", "get_logs", "(", "self", ",", "job_id", ")", ":", "response", ",", "http_response", "=", "self", ".", "_client", ".", "jobs", ".", "get_logs", "(", "job_id", "=", "job_id", ")", ".", "result", "(", ")", "if", "http_response", ".", "status_code", ...
Get logs of a job.
[ "Get", "logs", "of", "a", "job", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/api_client.py#L115-L122
reanahub/reana-commons
reana_commons/api_client.py
JobControllerAPIClient.check_if_cached
def check_if_cached(self, job_spec, step, workflow_workspace): """Check if job result is in cache.""" response, http_response = self._client.job_cache.check_if_cached( job_spec=json.dumps(job_spec), workflow_json=json.dumps(step), workflow_workspace=workflow_workspace...
python
def check_if_cached(self, job_spec, step, workflow_workspace): """Check if job result is in cache.""" response, http_response = self._client.job_cache.check_if_cached( job_spec=json.dumps(job_spec), workflow_json=json.dumps(step), workflow_workspace=workflow_workspace...
[ "def", "check_if_cached", "(", "self", ",", "job_spec", ",", "step", ",", "workflow_workspace", ")", ":", "response", ",", "http_response", "=", "self", ".", "_client", ".", "job_cache", ".", "check_if_cached", "(", "job_spec", "=", "json", ".", "dumps", "("...
Check if job result is in cache.
[ "Check", "if", "job", "result", "is", "in", "cache", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/api_client.py#L124-L137
reanahub/reana-commons
reana_commons/k8s/volumes.py
get_shared_volume
def get_shared_volume(workflow_workspace, shared_volume_root): """Get shared CephFS/hostPath volume to a given job spec. :param workflow_workspace: Absolute path to the job's workflow workspace. :param shared_volume_root: Root path in the underlying storage backend. :returns: Tuple consisting of the Ku...
python
def get_shared_volume(workflow_workspace, shared_volume_root): """Get shared CephFS/hostPath volume to a given job spec. :param workflow_workspace: Absolute path to the job's workflow workspace. :param shared_volume_root: Root path in the underlying storage backend. :returns: Tuple consisting of the Ku...
[ "def", "get_shared_volume", "(", "workflow_workspace", ",", "shared_volume_root", ")", ":", "workflow_workspace_relative_to_owner", "=", "workflow_workspace", "if", "os", ".", "path", ".", "isabs", "(", "workflow_workspace", ")", ":", "workflow_workspace_relative_to_owner",...
Get shared CephFS/hostPath volume to a given job spec. :param workflow_workspace: Absolute path to the job's workflow workspace. :param shared_volume_root: Root path in the underlying storage backend. :returns: Tuple consisting of the Kubernetes volumeMount and the volume.
[ "Get", "shared", "CephFS", "/", "hostPath", "volume", "to", "a", "given", "job", "spec", "." ]
train
https://github.com/reanahub/reana-commons/blob/abf31d9f495e0d93171c43fc4a414cd292091b11/reana_commons/k8s/volumes.py#L64-L87
jbaiter/gphoto2-cffi
gphoto2cffi/backend.py
_logging_callback
def _logging_callback(level, domain, message, data): """ Callback that outputs libgphoto2's logging message via Python's standard logging facilities. :param level: libgphoto2 logging level :param domain: component the message originates from :param message: logging message :param data: ...
python
def _logging_callback(level, domain, message, data): """ Callback that outputs libgphoto2's logging message via Python's standard logging facilities. :param level: libgphoto2 logging level :param domain: component the message originates from :param message: logging message :param data: ...
[ "def", "_logging_callback", "(", "level", ",", "domain", ",", "message", ",", "data", ")", ":", "domain", "=", "ffi", ".", "string", "(", "domain", ")", ".", "decode", "(", ")", "message", "=", "ffi", ".", "string", "(", "message", ")", ".", "decode"...
Callback that outputs libgphoto2's logging message via Python's standard logging facilities. :param level: libgphoto2 logging level :param domain: component the message originates from :param message: logging message :param data: Other data in the logging record (unused)
[ "Callback", "that", "outputs", "libgphoto2", "s", "logging", "message", "via", "Python", "s", "standard", "logging", "facilities", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/backend.py#L75-L90
jazzband/django-queued-storage
queued_storage/tasks.py
Transfer.run
def run(self, name, cache_key, local_path, remote_path, local_options, remote_options, **kwargs): """ The main work horse of the transfer task. Calls the transfer method with the local and remote storage backends as given with the parameters. :param name:...
python
def run(self, name, cache_key, local_path, remote_path, local_options, remote_options, **kwargs): """ The main work horse of the transfer task. Calls the transfer method with the local and remote storage backends as given with the parameters. :param name:...
[ "def", "run", "(", "self", ",", "name", ",", "cache_key", ",", "local_path", ",", "remote_path", ",", "local_options", ",", "remote_options", ",", "*", "*", "kwargs", ")", ":", "local", "=", "import_attribute", "(", "local_path", ")", "(", "*", "*", "loc...
The main work horse of the transfer task. Calls the transfer method with the local and remote storage backends as given with the parameters. :param name: name of the file to transfer :type name: str :param local_path: local storage class to transfer from :type local_path...
[ "The", "main", "work", "horse", "of", "the", "transfer", "task", ".", "Calls", "the", "transfer", "method", "with", "the", "local", "and", "remote", "storage", "backends", "as", "given", "with", "the", "parameters", "." ]
train
https://github.com/jazzband/django-queued-storage/blob/f8225d88a01ef5ca8001aeb3f7f80818a022a12d/queued_storage/tasks.py#L63-L100
jazzband/django-queued-storage
queued_storage/tasks.py
Transfer.transfer
def transfer(self, name, local, remote, **kwargs): """ Transfers the file with the given name from the local to the remote storage backend. :param name: The name of the file to transfer :param local: The local storage backend instance :param remote: The remote storage ba...
python
def transfer(self, name, local, remote, **kwargs): """ Transfers the file with the given name from the local to the remote storage backend. :param name: The name of the file to transfer :param local: The local storage backend instance :param remote: The remote storage ba...
[ "def", "transfer", "(", "self", ",", "name", ",", "local", ",", "remote", ",", "*", "*", "kwargs", ")", ":", "try", ":", "remote", ".", "save", "(", "name", ",", "local", ".", "open", "(", "name", ")", ")", "return", "True", "except", "Exception", ...
Transfers the file with the given name from the local to the remote storage backend. :param name: The name of the file to transfer :param local: The local storage backend instance :param remote: The remote storage backend instance :returns: `True` when the transfer succeeded, `F...
[ "Transfers", "the", "file", "with", "the", "given", "name", "from", "the", "local", "to", "the", "remote", "storage", "backend", "." ]
train
https://github.com/jazzband/django-queued-storage/blob/f8225d88a01ef5ca8001aeb3f7f80818a022a12d/queued_storage/tasks.py#L102-L121
jbaiter/gphoto2-cffi
gphoto2cffi/util.py
get_string
def get_string(cfunc, *args): """ Call a C function and return its return value as a Python string. :param cfunc: C function to call :param args: Arguments to call function with :rtype: str """ cstr = get_ctype("const char**", cfunc, *args) return backend.ffi.string(cstr).decod...
python
def get_string(cfunc, *args): """ Call a C function and return its return value as a Python string. :param cfunc: C function to call :param args: Arguments to call function with :rtype: str """ cstr = get_ctype("const char**", cfunc, *args) return backend.ffi.string(cstr).decod...
[ "def", "get_string", "(", "cfunc", ",", "*", "args", ")", ":", "cstr", "=", "get_ctype", "(", "\"const char**\"", ",", "cfunc", ",", "*", "args", ")", "return", "backend", ".", "ffi", ".", "string", "(", "cstr", ")", ".", "decode", "(", ")", "if", ...
Call a C function and return its return value as a Python string. :param cfunc: C function to call :param args: Arguments to call function with :rtype: str
[ "Call", "a", "C", "function", "and", "return", "its", "return", "value", "as", "a", "Python", "string", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/util.py#L26-L34
jbaiter/gphoto2-cffi
gphoto2cffi/util.py
get_ctype
def get_ctype(rtype, cfunc, *args): """ Call a C function that takes a pointer as its last argument and return the C object that it contains after the function has finished. :param rtype: C data type is filled by the function :param cfunc: C function to call :param args: Arguments to cal...
python
def get_ctype(rtype, cfunc, *args): """ Call a C function that takes a pointer as its last argument and return the C object that it contains after the function has finished. :param rtype: C data type is filled by the function :param cfunc: C function to call :param args: Arguments to cal...
[ "def", "get_ctype", "(", "rtype", ",", "cfunc", ",", "*", "args", ")", ":", "val_p", "=", "backend", ".", "ffi", ".", "new", "(", "rtype", ")", "args", "=", "args", "+", "(", "val_p", ",", ")", "cfunc", "(", "*", "args", ")", "return", "val_p", ...
Call a C function that takes a pointer as its last argument and return the C object that it contains after the function has finished. :param rtype: C data type is filled by the function :param cfunc: C function to call :param args: Arguments to call function with :return: A pointe...
[ "Call", "a", "C", "function", "that", "takes", "a", "pointer", "as", "its", "last", "argument", "and", "return", "the", "C", "object", "that", "it", "contains", "after", "the", "function", "has", "finished", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/util.py#L37-L49
jbaiter/gphoto2-cffi
gphoto2cffi/util.py
new_gp_object
def new_gp_object(typename): """ Create an indirect pointer to a GPhoto2 type, call its matching constructor function and return the pointer to it. :param typename: Name of the type to create. :return: A pointer to the specified data type. """ obj_p = backend.ffi.new("{0}**".f...
python
def new_gp_object(typename): """ Create an indirect pointer to a GPhoto2 type, call its matching constructor function and return the pointer to it. :param typename: Name of the type to create. :return: A pointer to the specified data type. """ obj_p = backend.ffi.new("{0}**".f...
[ "def", "new_gp_object", "(", "typename", ")", ":", "obj_p", "=", "backend", ".", "ffi", ".", "new", "(", "\"{0}**\"", ".", "format", "(", "typename", ")", ")", "backend", ".", "CONSTRUCTORS", "[", "typename", "]", "(", "obj_p", ")", "return", "obj_p", ...
Create an indirect pointer to a GPhoto2 type, call its matching constructor function and return the pointer to it. :param typename: Name of the type to create. :return: A pointer to the specified data type.
[ "Create", "an", "indirect", "pointer", "to", "a", "GPhoto2", "type", "call", "its", "matching", "constructor", "function", "and", "return", "the", "pointer", "to", "it", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/util.py#L52-L61
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
get_library_version
def get_library_version(): """ Get the version number of the underlying gphoto2 library. :return: The version :rtype: tuple of (major, minor, patch) version numbers """ version_str = ffi.string(lib.gp_library_version(True)[0]).decode() return tuple(int(x) for x in version_str.split('.'))
python
def get_library_version(): """ Get the version number of the underlying gphoto2 library. :return: The version :rtype: tuple of (major, minor, patch) version numbers """ version_str = ffi.string(lib.gp_library_version(True)[0]).decode() return tuple(int(x) for x in version_str.split('.'))
[ "def", "get_library_version", "(", ")", ":", "version_str", "=", "ffi", ".", "string", "(", "lib", ".", "gp_library_version", "(", "True", ")", "[", "0", "]", ")", ".", "decode", "(", ")", "return", "tuple", "(", "int", "(", "x", ")", "for", "x", "...
Get the version number of the underlying gphoto2 library. :return: The version :rtype: tuple of (major, minor, patch) version numbers
[ "Get", "the", "version", "number", "of", "the", "underlying", "gphoto2", "library", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L23-L30
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
list_cameras
def list_cameras(): """ List all attached USB cameras that are supported by libgphoto2. :return: All recognized cameras :rtype: list of :py:class:`Camera` """ ctx = lib.gp_context_new() camlist_p = new_gp_object("CameraList") port_list_p = new_gp_object("GPPortInfoList") lib.gp_p...
python
def list_cameras(): """ List all attached USB cameras that are supported by libgphoto2. :return: All recognized cameras :rtype: list of :py:class:`Camera` """ ctx = lib.gp_context_new() camlist_p = new_gp_object("CameraList") port_list_p = new_gp_object("GPPortInfoList") lib.gp_p...
[ "def", "list_cameras", "(", ")", ":", "ctx", "=", "lib", ".", "gp_context_new", "(", ")", "camlist_p", "=", "new_gp_object", "(", "\"CameraList\"", ")", "port_list_p", "=", "new_gp_object", "(", "\"GPPortInfoList\"", ")", "lib", ".", "gp_port_info_list_load", "(...
List all attached USB cameras that are supported by libgphoto2. :return: All recognized cameras :rtype: list of :py:class:`Camera`
[ "List", "all", "attached", "USB", "cameras", "that", "are", "supported", "by", "libgphoto2", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L33-L69
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
supported_cameras
def supported_cameras(): """ List the names of all cameras supported by libgphoto2, grouped by the name of their driver. """ ctx = lib.gp_context_new() abilities_list_p = new_gp_object("CameraAbilitiesList") lib.gp_abilities_list_load(abilities_list_p, ctx) abilities = ffi.new("CameraAbiliti...
python
def supported_cameras(): """ List the names of all cameras supported by libgphoto2, grouped by the name of their driver. """ ctx = lib.gp_context_new() abilities_list_p = new_gp_object("CameraAbilitiesList") lib.gp_abilities_list_load(abilities_list_p, ctx) abilities = ffi.new("CameraAbiliti...
[ "def", "supported_cameras", "(", ")", ":", "ctx", "=", "lib", ".", "gp_context_new", "(", ")", "abilities_list_p", "=", "new_gp_object", "(", "\"CameraAbilitiesList\"", ")", "lib", ".", "gp_abilities_list_load", "(", "abilities_list_p", ",", "ctx", ")", "abilities...
List the names of all cameras supported by libgphoto2, grouped by the name of their driver.
[ "List", "the", "names", "of", "all", "cameras", "supported", "by", "libgphoto2", "grouped", "by", "the", "name", "of", "their", "driver", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L72-L92
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
VideoCaptureContext.stop
def stop(self): """ Stop the capture. """ self.camera._get_config()['actions']['movie'].set(False) self.videofile = self.camera._wait_for_event( event_type=lib.GP_EVENT_FILE_ADDED) if self._old_captarget != "Memory card": self.camera.config['settings']['capturetar...
python
def stop(self): """ Stop the capture. """ self.camera._get_config()['actions']['movie'].set(False) self.videofile = self.camera._wait_for_event( event_type=lib.GP_EVENT_FILE_ADDED) if self._old_captarget != "Memory card": self.camera.config['settings']['capturetar...
[ "def", "stop", "(", "self", ")", ":", "self", ".", "camera", ".", "_get_config", "(", ")", "[", "'actions'", "]", "[", "'movie'", "]", ".", "set", "(", "False", ")", "self", ".", "videofile", "=", "self", ".", "camera", ".", "_wait_for_event", "(", ...
Stop the capture.
[ "Stop", "the", "capture", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L154-L161
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
Directory.path
def path(self): """ Absolute path to the directory on the camera's filesystem. """ if self.parent is None: return "/" else: return os.path.join(self.parent.path, self.name)
python
def path(self): """ Absolute path to the directory on the camera's filesystem. """ if self.parent is None: return "/" else: return os.path.join(self.parent.path, self.name)
[ "def", "path", "(", "self", ")", ":", "if", "self", ".", "parent", "is", "None", ":", "return", "\"/\"", "else", ":", "return", "os", ".", "path", ".", "join", "(", "self", ".", "parent", ".", "path", ",", "self", ".", "name", ")" ]
Absolute path to the directory on the camera's filesystem.
[ "Absolute", "path", "to", "the", "directory", "on", "the", "camera", "s", "filesystem", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L182-L187
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
Directory.supported_operations
def supported_operations(self): """ All directory operations supported by the camera. """ return tuple(op for op in backend.DIR_OPS if self._dir_ops & op)
python
def supported_operations(self): """ All directory operations supported by the camera. """ return tuple(op for op in backend.DIR_OPS if self._dir_ops & op)
[ "def", "supported_operations", "(", "self", ")", ":", "return", "tuple", "(", "op", "for", "op", "in", "backend", ".", "DIR_OPS", "if", "self", ".", "_dir_ops", "&", "op", ")" ]
All directory operations supported by the camera.
[ "All", "directory", "operations", "supported", "by", "the", "camera", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L190-L192
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
Directory.exists
def exists(self): """ Check whether the directory exists on the camera. """ if self.name in ("", "/") and self.parent is None: return True else: return self in self.parent.directories
python
def exists(self): """ Check whether the directory exists on the camera. """ if self.name in ("", "/") and self.parent is None: return True else: return self in self.parent.directories
[ "def", "exists", "(", "self", ")", ":", "if", "self", ".", "name", "in", "(", "\"\"", ",", "\"/\"", ")", "and", "self", ".", "parent", "is", "None", ":", "return", "True", "else", ":", "return", "self", "in", "self", ".", "parent", ".", "directorie...
Check whether the directory exists on the camera.
[ "Check", "whether", "the", "directory", "exists", "on", "the", "camera", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L195-L200
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
Directory.files
def files(self): """ Get a generator that yields all files in the directory. """ filelist_p = new_gp_object("CameraList") lib.gp_camera_folder_list_files(self._cam._cam, self.path.encode(), filelist_p, self._cam._ctx) for idx in range(lib.gp_list_c...
python
def files(self): """ Get a generator that yields all files in the directory. """ filelist_p = new_gp_object("CameraList") lib.gp_camera_folder_list_files(self._cam._cam, self.path.encode(), filelist_p, self._cam._ctx) for idx in range(lib.gp_list_c...
[ "def", "files", "(", "self", ")", ":", "filelist_p", "=", "new_gp_object", "(", "\"CameraList\"", ")", "lib", ".", "gp_camera_folder_list_files", "(", "self", ".", "_cam", ".", "_cam", ",", "self", ".", "path", ".", "encode", "(", ")", ",", "filelist_p", ...
Get a generator that yields all files in the directory.
[ "Get", "a", "generator", "that", "yields", "all", "files", "in", "the", "directory", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L204-L212
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
Directory.directories
def directories(self): """ Get a generator that yields all subdirectories in the directory. """ dirlist_p = new_gp_object("CameraList") lib.gp_camera_folder_list_folders(self._cam._cam, self.path.encode(), dirlist_p, self._cam._ctx) for i...
python
def directories(self): """ Get a generator that yields all subdirectories in the directory. """ dirlist_p = new_gp_object("CameraList") lib.gp_camera_folder_list_folders(self._cam._cam, self.path.encode(), dirlist_p, self._cam._ctx) for i...
[ "def", "directories", "(", "self", ")", ":", "dirlist_p", "=", "new_gp_object", "(", "\"CameraList\"", ")", "lib", ".", "gp_camera_folder_list_folders", "(", "self", ".", "_cam", ".", "_cam", ",", "self", ".", "path", ".", "encode", "(", ")", ",", "dirlist...
Get a generator that yields all subdirectories in the directory.
[ "Get", "a", "generator", "that", "yields", "all", "subdirectories", "in", "the", "directory", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L216-L226
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
Directory.create
def create(self): """ Create the directory. """ lib.gp_camera_folder_make_dir( self._cam._cam, self.parent.path.encode(), self.name.encode(), self._cam._ctx)
python
def create(self): """ Create the directory. """ lib.gp_camera_folder_make_dir( self._cam._cam, self.parent.path.encode(), self.name.encode(), self._cam._ctx)
[ "def", "create", "(", "self", ")", ":", "lib", ".", "gp_camera_folder_make_dir", "(", "self", ".", "_cam", ".", "_cam", ",", "self", ".", "parent", ".", "path", ".", "encode", "(", ")", ",", "self", ".", "name", ".", "encode", "(", ")", ",", "self"...
Create the directory.
[ "Create", "the", "directory", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L229-L233
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
Directory.remove
def remove(self): """ Remove the directory. """ lib.gp_camera_folder_remove_dir( self._cam._cam, self.parent.path.encode(), self.name.encode(), self._cam._ctx)
python
def remove(self): """ Remove the directory. """ lib.gp_camera_folder_remove_dir( self._cam._cam, self.parent.path.encode(), self.name.encode(), self._cam._ctx)
[ "def", "remove", "(", "self", ")", ":", "lib", ".", "gp_camera_folder_remove_dir", "(", "self", ".", "_cam", ".", "_cam", ",", "self", ".", "parent", ".", "path", ".", "encode", "(", ")", ",", "self", ".", "name", ".", "encode", "(", ")", ",", "sel...
Remove the directory.
[ "Remove", "the", "directory", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L236-L240
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
Directory.upload
def upload(self, local_path): """ Upload a file to the camera's permanent storage. :param local_path: Path to file to copy :type local_path: str/unicode """ camerafile_p = ffi.new("CameraFile**") with open(local_path, 'rb') as fp: lib.gp_file_new_from_fd(cam...
python
def upload(self, local_path): """ Upload a file to the camera's permanent storage. :param local_path: Path to file to copy :type local_path: str/unicode """ camerafile_p = ffi.new("CameraFile**") with open(local_path, 'rb') as fp: lib.gp_file_new_from_fd(cam...
[ "def", "upload", "(", "self", ",", "local_path", ")", ":", "camerafile_p", "=", "ffi", ".", "new", "(", "\"CameraFile**\"", ")", "with", "open", "(", "local_path", ",", "'rb'", ")", "as", "fp", ":", "lib", ".", "gp_file_new_from_fd", "(", "camerafile_p", ...
Upload a file to the camera's permanent storage. :param local_path: Path to file to copy :type local_path: str/unicode
[ "Upload", "a", "file", "to", "the", "camera", "s", "permanent", "storage", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L243-L256
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
File.supported_operations
def supported_operations(self): """ All file operations supported by the camera. """ return tuple(op for op in backend.FILE_OPS if self._operations & op)
python
def supported_operations(self): """ All file operations supported by the camera. """ return tuple(op for op in backend.FILE_OPS if self._operations & op)
[ "def", "supported_operations", "(", "self", ")", ":", "return", "tuple", "(", "op", "for", "op", "in", "backend", ".", "FILE_OPS", "if", "self", ".", "_operations", "&", "op", ")" ]
All file operations supported by the camera.
[ "All", "file", "operations", "supported", "by", "the", "camera", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L277-L279
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
File.dimensions
def dimensions(self): """ Dimensions of the image. :rtype: :py:class:`ImageDimensions` """ return ImageDimensions(self._info.file.width, self._info.file.height)
python
def dimensions(self): """ Dimensions of the image. :rtype: :py:class:`ImageDimensions` """ return ImageDimensions(self._info.file.width, self._info.file.height)
[ "def", "dimensions", "(", "self", ")", ":", "return", "ImageDimensions", "(", "self", ".", "_info", ".", "file", ".", "width", ",", "self", ".", "_info", ".", "file", ".", "height", ")" ]
Dimensions of the image. :rtype: :py:class:`ImageDimensions`
[ "Dimensions", "of", "the", "image", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L298-L303
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
File.permissions
def permissions(self): """ Permissions of the file. Can be "r-" (read-only), "-w" (write-only), "rw" (read-write) or "--" (no rights). :rtype: str """ can_read = self._info.file.permissions & lib.GP_FILE_PERM_READ can_write = self._info.file.permissions & lib.GP...
python
def permissions(self): """ Permissions of the file. Can be "r-" (read-only), "-w" (write-only), "rw" (read-write) or "--" (no rights). :rtype: str """ can_read = self._info.file.permissions & lib.GP_FILE_PERM_READ can_write = self._info.file.permissions & lib.GP...
[ "def", "permissions", "(", "self", ")", ":", "can_read", "=", "self", ".", "_info", ".", "file", ".", "permissions", "&", "lib", ".", "GP_FILE_PERM_READ", "can_write", "=", "self", ".", "_info", ".", "file", ".", "permissions", "&", "lib", ".", "GP_FILE_...
Permissions of the file. Can be "r-" (read-only), "-w" (write-only), "rw" (read-write) or "--" (no rights). :rtype: str
[ "Permissions", "of", "the", "file", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L306-L317
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
File.save
def save(self, target_path, ftype='normal'): """ Save file content to a local file. :param target_path: Path to save remote file as. :type target_path: str/unicode :param ftype: Select 'view' on file. :type ftype: str """ camfile_p = ffi.new("Camera...
python
def save(self, target_path, ftype='normal'): """ Save file content to a local file. :param target_path: Path to save remote file as. :type target_path: str/unicode :param ftype: Select 'view' on file. :type ftype: str """ camfile_p = ffi.new("Camera...
[ "def", "save", "(", "self", ",", "target_path", ",", "ftype", "=", "'normal'", ")", ":", "camfile_p", "=", "ffi", ".", "new", "(", "\"CameraFile**\"", ")", "with", "open", "(", "target_path", ",", "'wb'", ")", "as", "fp", ":", "lib", ".", "gp_file_new_...
Save file content to a local file. :param target_path: Path to save remote file as. :type target_path: str/unicode :param ftype: Select 'view' on file. :type ftype: str
[ "Save", "file", "content", "to", "a", "local", "file", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L328-L342
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
File.get_data
def get_data(self, ftype='normal'): """ Get file content as a bytestring. :param ftype: Select 'view' on file. :type ftype: str :return: File content :rtype: bytes """ camfile_p = ffi.new("CameraFile**") lib.gp_file_new...
python
def get_data(self, ftype='normal'): """ Get file content as a bytestring. :param ftype: Select 'view' on file. :type ftype: str :return: File content :rtype: bytes """ camfile_p = ffi.new("CameraFile**") lib.gp_file_new...
[ "def", "get_data", "(", "self", ",", "ftype", "=", "'normal'", ")", ":", "camfile_p", "=", "ffi", ".", "new", "(", "\"CameraFile**\"", ")", "lib", ".", "gp_file_new", "(", "camfile_p", ")", "lib", ".", "gp_camera_file_get", "(", "self", ".", "_cam", ".",...
Get file content as a bytestring. :param ftype: Select 'view' on file. :type ftype: str :return: File content :rtype: bytes
[ "Get", "file", "content", "as", "a", "bytestring", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L345-L366
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
File.iter_data
def iter_data(self, chunk_size=2**16, ftype='normal'): """ Get an iterator that yields chunks of the file content. :param chunk_size: Size of yielded chunks in bytes :type chunk_size: int :param ftype: Select 'view' on file. :type ftype: str :return: ...
python
def iter_data(self, chunk_size=2**16, ftype='normal'): """ Get an iterator that yields chunks of the file content. :param chunk_size: Size of yielded chunks in bytes :type chunk_size: int :param ftype: Select 'view' on file. :type ftype: str :return: ...
[ "def", "iter_data", "(", "self", ",", "chunk_size", "=", "2", "**", "16", ",", "ftype", "=", "'normal'", ")", ":", "self", ".", "_check_type_supported", "(", "ftype", ")", "buf_p", "=", "ffi", ".", "new", "(", "\"char[{0}]\"", ".", "format", "(", "chun...
Get an iterator that yields chunks of the file content. :param chunk_size: Size of yielded chunks in bytes :type chunk_size: int :param ftype: Select 'view' on file. :type ftype: str :return: Iterator
[ "Get", "an", "iterator", "that", "yields", "chunks", "of", "the", "file", "content", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L369-L388
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
File.remove
def remove(self): """ Remove file from device. """ lib.gp_camera_file_delete(self._cam._cam, self.directory.path.encode(), self.name.encode(), self._cam._ctx)
python
def remove(self): """ Remove file from device. """ lib.gp_camera_file_delete(self._cam._cam, self.directory.path.encode(), self.name.encode(), self._cam._ctx)
[ "def", "remove", "(", "self", ")", ":", "lib", ".", "gp_camera_file_delete", "(", "self", ".", "_cam", ".", "_cam", ",", "self", ".", "directory", ".", "path", ".", "encode", "(", ")", ",", "self", ".", "name", ".", "encode", "(", ")", ",", "self",...
Remove file from device.
[ "Remove", "file", "from", "device", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L391-L394
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
ConfigItem.set
def set(self, value): """ Update value of the option. Only possible for options with :py:attr:`readonly` set to `False`. If :py:attr:`type` is `choice`, the value must be one of the :py:attr:`choices`. If :py:attr:`type` is `range`, the value must be in the range describ...
python
def set(self, value): """ Update value of the option. Only possible for options with :py:attr:`readonly` set to `False`. If :py:attr:`type` is `choice`, the value must be one of the :py:attr:`choices`. If :py:attr:`type` is `range`, the value must be in the range describ...
[ "def", "set", "(", "self", ",", "value", ")", ":", "if", "self", ".", "readonly", ":", "raise", "ValueError", "(", "\"Option is read-only.\"", ")", "val_p", "=", "None", "if", "self", ".", "type", "==", "'selection'", ":", "if", "value", "not", "in", "...
Update value of the option. Only possible for options with :py:attr:`readonly` set to `False`. If :py:attr:`type` is `choice`, the value must be one of the :py:attr:`choices`. If :py:attr:`type` is `range`, the value must be in the range described by :py:attr:`range`. :...
[ "Update", "value", "of", "the", "option", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L468-L511
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
Camera.supported_operations
def supported_operations(self): """ All operations supported by the camera. """ return tuple(op for op in backend.CAM_OPS if self._abilities.operations & op)
python
def supported_operations(self): """ All operations supported by the camera. """ return tuple(op for op in backend.CAM_OPS if self._abilities.operations & op)
[ "def", "supported_operations", "(", "self", ")", ":", "return", "tuple", "(", "op", "for", "op", "in", "backend", ".", "CAM_OPS", "if", "self", ".", "_abilities", ".", "operations", "&", "op", ")" ]
All operations supported by the camera.
[ "All", "operations", "supported", "by", "the", "camera", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L571-L574
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
Camera.usb_info
def usb_info(self): """ The camera's USB information. """ return UsbInformation(self._abilities.usb_vendor, self._abilities.usb_product, self._abilities.usb_class, self._abilities.usb_subclass, ...
python
def usb_info(self): """ The camera's USB information. """ return UsbInformation(self._abilities.usb_vendor, self._abilities.usb_product, self._abilities.usb_class, self._abilities.usb_subclass, ...
[ "def", "usb_info", "(", "self", ")", ":", "return", "UsbInformation", "(", "self", ".", "_abilities", ".", "usb_vendor", ",", "self", ".", "_abilities", ".", "usb_product", ",", "self", ".", "_abilities", ".", "usb_class", ",", "self", ".", "_abilities", "...
The camera's USB information.
[ "The", "camera", "s", "USB", "information", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L577-L583
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
Camera.config
def config(self): """ Writeable configuration parameters. :rtype: dict """ config = self._get_config() return {section: {itm.name: itm for itm in config[section].values() if not itm.readonly} for section in config if ...
python
def config(self): """ Writeable configuration parameters. :rtype: dict """ config = self._get_config() return {section: {itm.name: itm for itm in config[section].values() if not itm.readonly} for section in config if ...
[ "def", "config", "(", "self", ")", ":", "config", "=", "self", ".", "_get_config", "(", ")", "return", "{", "section", ":", "{", "itm", ".", "name", ":", "itm", "for", "itm", "in", "config", "[", "section", "]", ".", "values", "(", ")", "if", "no...
Writeable configuration parameters. :rtype: dict
[ "Writeable", "configuration", "parameters", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L591-L600
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
Camera.status
def status(self): """ Status information (read-only). :rtype: :py:class:`SimpleNamespace` """ config = self._get_config() is_hex = lambda name: (len(name) == 4 and all(c in string.hexdigits for c in name)) out = SimpleNamespace() ...
python
def status(self): """ Status information (read-only). :rtype: :py:class:`SimpleNamespace` """ config = self._get_config() is_hex = lambda name: (len(name) == 4 and all(c in string.hexdigits for c in name)) out = SimpleNamespace() ...
[ "def", "status", "(", "self", ")", ":", "config", "=", "self", ".", "_get_config", "(", ")", "is_hex", "=", "lambda", "name", ":", "(", "len", "(", "name", ")", "==", "4", "and", "all", "(", "c", "in", "string", ".", "hexdigits", "for", "c", "in"...
Status information (read-only). :rtype: :py:class:`SimpleNamespace`
[ "Status", "information", "(", "read", "-", "only", ")", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L603-L616
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
Camera.storage_info
def storage_info(self): """ Information about the camera's storage. """ info_p = ffi.new("CameraStorageInformation**") num_info_p = ffi.new("int*") lib.gp_camera_get_storageinfo(self._cam, info_p, num_info_p, self._ctx) infos = [] for idx in range(num_info_p[0]): ...
python
def storage_info(self): """ Information about the camera's storage. """ info_p = ffi.new("CameraStorageInformation**") num_info_p = ffi.new("int*") lib.gp_camera_get_storageinfo(self._cam, info_p, num_info_p, self._ctx) infos = [] for idx in range(num_info_p[0]): ...
[ "def", "storage_info", "(", "self", ")", ":", "info_p", "=", "ffi", ".", "new", "(", "\"CameraStorageInformation**\"", ")", "num_info_p", "=", "ffi", ".", "new", "(", "\"int*\"", ")", "lib", ".", "gp_camera_get_storageinfo", "(", "self", ".", "_cam", ",", ...
Information about the camera's storage.
[ "Information", "about", "the", "camera", "s", "storage", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L625-L670
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
Camera.list_all_files
def list_all_files(self): """ Utility method that yields all files on the device's file systems. """ def list_files_recursively(directory): f_gen = itertools.chain( directory.files, *tuple(list_files_recursively(d) fo...
python
def list_all_files(self): """ Utility method that yields all files on the device's file systems. """ def list_files_recursively(directory): f_gen = itertools.chain( directory.files, *tuple(list_files_recursively(d) fo...
[ "def", "list_all_files", "(", "self", ")", ":", "def", "list_files_recursively", "(", "directory", ")", ":", "f_gen", "=", "itertools", ".", "chain", "(", "directory", ".", "files", ",", "*", "tuple", "(", "list_files_recursively", "(", "d", ")", "for", "d...
Utility method that yields all files on the device's file systems.
[ "Utility", "method", "that", "yields", "all", "files", "on", "the", "device", "s", "file", "systems", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L672-L683
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
Camera.list_all_directories
def list_all_directories(self): """ Utility method that yields all directories on the device's file systems. """ def list_dirs_recursively(directory): if directory == self.filesystem: yield directory d_gen = itertools.chain( dir...
python
def list_all_directories(self): """ Utility method that yields all directories on the device's file systems. """ def list_dirs_recursively(directory): if directory == self.filesystem: yield directory d_gen = itertools.chain( dir...
[ "def", "list_all_directories", "(", "self", ")", ":", "def", "list_dirs_recursively", "(", "directory", ")", ":", "if", "directory", "==", "self", ".", "filesystem", ":", "yield", "directory", "d_gen", "=", "itertools", ".", "chain", "(", "directory", ".", "...
Utility method that yields all directories on the device's file systems.
[ "Utility", "method", "that", "yields", "all", "directories", "on", "the", "device", "s", "file", "systems", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L685-L698
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
Camera.capture
def capture(self, to_camera_storage=False): """ Capture an image. Some cameras (mostly Canon and Nikon) support capturing to internal RAM. On these devices, you have to specify `to_camera_storage` if you want to save the images to the memory card. On devices that do not support ...
python
def capture(self, to_camera_storage=False): """ Capture an image. Some cameras (mostly Canon and Nikon) support capturing to internal RAM. On these devices, you have to specify `to_camera_storage` if you want to save the images to the memory card. On devices that do not support ...
[ "def", "capture", "(", "self", ",", "to_camera_storage", "=", "False", ")", ":", "target", "=", "self", ".", "config", "[", "'settings'", "]", "[", "'capturetarget'", "]", "if", "to_camera_storage", "and", "target", ".", "value", "!=", "\"Memory card\"", ":"...
Capture an image. Some cameras (mostly Canon and Nikon) support capturing to internal RAM. On these devices, you have to specify `to_camera_storage` if you want to save the images to the memory card. On devices that do not support saving to RAM, the only difference is that the file ...
[ "Capture", "an", "image", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L701-L735
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
Camera.capture_video
def capture_video(self, length): """ Capture a video. This always writes to the memory card, since internal RAM is likely to run out of space very quickly. Currently this only works with Nikon cameras. :param length: Length of the video to capture in seconds. :typ...
python
def capture_video(self, length): """ Capture a video. This always writes to the memory card, since internal RAM is likely to run out of space very quickly. Currently this only works with Nikon cameras. :param length: Length of the video to capture in seconds. :typ...
[ "def", "capture_video", "(", "self", ",", "length", ")", ":", "with", "self", ".", "capture_video_context", "(", ")", "as", "ctx", ":", "time", ".", "sleep", "(", "length", ")", "return", "ctx", ".", "videofile" ]
Capture a video. This always writes to the memory card, since internal RAM is likely to run out of space very quickly. Currently this only works with Nikon cameras. :param length: Length of the video to capture in seconds. :type length: int :return: ...
[ "Capture", "a", "video", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L747-L762
jbaiter/gphoto2-cffi
gphoto2cffi/gphoto2.py
Camera.get_preview
def get_preview(self): """ Get a preview from the camera's viewport. This will usually be a JPEG image with the dimensions depending on the camera. You will need to call the exit() method manually after you are done capturing a live preview. :return: The preview image as a ...
python
def get_preview(self): """ Get a preview from the camera's viewport. This will usually be a JPEG image with the dimensions depending on the camera. You will need to call the exit() method manually after you are done capturing a live preview. :return: The preview image as a ...
[ "def", "get_preview", "(", "self", ")", ":", "lib", ".", "gp_camera_capture_preview", "(", "self", ".", "_cam", ",", "self", ".", "__camfile_p", "[", "0", "]", ",", "self", ".", "_ctx", ")", "lib", ".", "gp_file_get_data_and_size", "(", "self", ".", "__c...
Get a preview from the camera's viewport. This will usually be a JPEG image with the dimensions depending on the camera. You will need to call the exit() method manually after you are done capturing a live preview. :return: The preview image as a bytestring :rtype: byte...
[ "Get", "a", "preview", "from", "the", "camera", "s", "viewport", "." ]
train
https://github.com/jbaiter/gphoto2-cffi/blob/2876d15a58174bd24613cd4106a3ef0cefd48050/gphoto2cffi/gphoto2.py#L764-L776
jazzband/django-queued-storage
queued_storage/backends.py
QueuedStorage.get_storage
def get_storage(self, name): """ Returns the storage backend instance responsible for the file with the given name (either local or remote). This method is used in most of the storage API methods. :param name: file name :type name: str :rtype: :class:`~django:dja...
python
def get_storage(self, name): """ Returns the storage backend instance responsible for the file with the given name (either local or remote). This method is used in most of the storage API methods. :param name: file name :type name: str :rtype: :class:`~django:dja...
[ "def", "get_storage", "(", "self", ",", "name", ")", ":", "cache_result", "=", "cache", ".", "get", "(", "self", ".", "get_cache_key", "(", "name", ")", ")", "if", "cache_result", ":", "return", "self", ".", "remote", "elif", "cache_result", "is", "None"...
Returns the storage backend instance responsible for the file with the given name (either local or remote). This method is used in most of the storage API methods. :param name: file name :type name: str :rtype: :class:`~django:django.core.files.storage.Storage`
[ "Returns", "the", "storage", "backend", "instance", "responsible", "for", "the", "file", "with", "the", "given", "name", "(", "either", "local", "or", "remote", ")", ".", "This", "method", "is", "used", "in", "most", "of", "the", "storage", "API", "methods...
train
https://github.com/jazzband/django-queued-storage/blob/f8225d88a01ef5ca8001aeb3f7f80818a022a12d/queued_storage/backends.py#L111-L128
jazzband/django-queued-storage
queued_storage/backends.py
QueuedStorage.open
def open(self, name, mode='rb'): """ Retrieves the specified file from storage. :param name: file name :type name: str :param mode: mode to open the file with :type mode: str :rtype: :class:`~django:django.core.files.File` """ return self.get_stor...
python
def open(self, name, mode='rb'): """ Retrieves the specified file from storage. :param name: file name :type name: str :param mode: mode to open the file with :type mode: str :rtype: :class:`~django:django.core.files.File` """ return self.get_stor...
[ "def", "open", "(", "self", ",", "name", ",", "mode", "=", "'rb'", ")", ":", "return", "self", ".", "get_storage", "(", "name", ")", ".", "open", "(", "name", ",", "mode", ")" ]
Retrieves the specified file from storage. :param name: file name :type name: str :param mode: mode to open the file with :type mode: str :rtype: :class:`~django:django.core.files.File`
[ "Retrieves", "the", "specified", "file", "from", "storage", "." ]
train
https://github.com/jazzband/django-queued-storage/blob/f8225d88a01ef5ca8001aeb3f7f80818a022a12d/queued_storage/backends.py#L162-L172
jazzband/django-queued-storage
queued_storage/backends.py
QueuedStorage.save
def save(self, name, content, max_length=None): """ Saves the given content with the given name using the local storage. If the :attr:`~queued_storage.backends.QueuedStorage.delayed` attribute is ``True`` this will automatically call the :meth:`~queued_storage.backends.QueuedStor...
python
def save(self, name, content, max_length=None): """ Saves the given content with the given name using the local storage. If the :attr:`~queued_storage.backends.QueuedStorage.delayed` attribute is ``True`` this will automatically call the :meth:`~queued_storage.backends.QueuedStor...
[ "def", "save", "(", "self", ",", "name", ",", "content", ",", "max_length", "=", "None", ")", ":", "cache_key", "=", "self", ".", "get_cache_key", "(", "name", ")", "cache", ".", "set", "(", "cache_key", ",", "False", ")", "# Use a name that is available o...
Saves the given content with the given name using the local storage. If the :attr:`~queued_storage.backends.QueuedStorage.delayed` attribute is ``True`` this will automatically call the :meth:`~queued_storage.backends.QueuedStorage.transfer` method queuing the transfer from local to remo...
[ "Saves", "the", "given", "content", "with", "the", "given", "name", "using", "the", "local", "storage", ".", "If", "the", ":", "attr", ":", "~queued_storage", ".", "backends", ".", "QueuedStorage", ".", "delayed", "attribute", "is", "True", "this", "will", ...
train
https://github.com/jazzband/django-queued-storage/blob/f8225d88a01ef5ca8001aeb3f7f80818a022a12d/queued_storage/backends.py#L174-L204
jazzband/django-queued-storage
queued_storage/backends.py
QueuedStorage.transfer
def transfer(self, name, cache_key=None): """ Transfers the file with the given name to the remote storage backend by queuing the task. :param name: file name :type name: str :param cache_key: the cache key to set after a successful task run :type cache_key: str ...
python
def transfer(self, name, cache_key=None): """ Transfers the file with the given name to the remote storage backend by queuing the task. :param name: file name :type name: str :param cache_key: the cache key to set after a successful task run :type cache_key: str ...
[ "def", "transfer", "(", "self", ",", "name", ",", "cache_key", "=", "None", ")", ":", "if", "cache_key", "is", "None", ":", "cache_key", "=", "self", ".", "get_cache_key", "(", "name", ")", "return", "self", ".", "task", ".", "delay", "(", "name", ",...
Transfers the file with the given name to the remote storage backend by queuing the task. :param name: file name :type name: str :param cache_key: the cache key to set after a successful task run :type cache_key: str :rtype: task result
[ "Transfers", "the", "file", "with", "the", "given", "name", "to", "the", "remote", "storage", "backend", "by", "queuing", "the", "task", "." ]
train
https://github.com/jazzband/django-queued-storage/blob/f8225d88a01ef5ca8001aeb3f7f80818a022a12d/queued_storage/backends.py#L206-L221
jazzband/django-queued-storage
queued_storage/backends.py
QueuedStorage.get_available_name
def get_available_name(self, name): """ Returns a filename that's free on both the local and remote storage systems, and available for new content to be written to. :param name: file name :type name: str :rtype: str """ local_available_name = self.local.g...
python
def get_available_name(self, name): """ Returns a filename that's free on both the local and remote storage systems, and available for new content to be written to. :param name: file name :type name: str :rtype: str """ local_available_name = self.local.g...
[ "def", "get_available_name", "(", "self", ",", "name", ")", ":", "local_available_name", "=", "self", ".", "local", ".", "get_available_name", "(", "name", ")", "remote_available_name", "=", "self", ".", "remote", ".", "get_available_name", "(", "name", ")", "...
Returns a filename that's free on both the local and remote storage systems, and available for new content to be written to. :param name: file name :type name: str :rtype: str
[ "Returns", "a", "filename", "that", "s", "free", "on", "both", "the", "local", "and", "remote", "storage", "systems", "and", "available", "for", "new", "content", "to", "be", "written", "to", "." ]
train
https://github.com/jazzband/django-queued-storage/blob/f8225d88a01ef5ca8001aeb3f7f80818a022a12d/queued_storage/backends.py#L234-L248
mongolab/dex
dex/analyzer.py
QueryAnalyzer.generate_query_report
def generate_query_report(self, db_uri, parsed_query, db_name, collection_name): """Generates a comprehensive report on the raw query""" index_analysis = None recommendation = None namespace = parsed_query['ns'] indexStatus = "unknown" index_cache_entry = self._ensure_in...
python
def generate_query_report(self, db_uri, parsed_query, db_name, collection_name): """Generates a comprehensive report on the raw query""" index_analysis = None recommendation = None namespace = parsed_query['ns'] indexStatus = "unknown" index_cache_entry = self._ensure_in...
[ "def", "generate_query_report", "(", "self", ",", "db_uri", ",", "parsed_query", ",", "db_name", ",", "collection_name", ")", ":", "index_analysis", "=", "None", "recommendation", "=", "None", "namespace", "=", "parsed_query", "[", "'ns'", "]", "indexStatus", "=...
Generates a comprehensive report on the raw query
[ "Generates", "a", "comprehensive", "report", "on", "the", "raw", "query" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/analyzer.py#L47-L88
mongolab/dex
dex/analyzer.py
QueryAnalyzer._ensure_index_cache
def _ensure_index_cache(self, db_uri, db_name, collection_name): """Adds a collections index entries to the cache if not present""" if not self._check_indexes or db_uri is None: return {'indexes': None} if db_name not in self.get_cache(): self._internal_map[db_name] = {} ...
python
def _ensure_index_cache(self, db_uri, db_name, collection_name): """Adds a collections index entries to the cache if not present""" if not self._check_indexes or db_uri is None: return {'indexes': None} if db_name not in self.get_cache(): self._internal_map[db_name] = {} ...
[ "def", "_ensure_index_cache", "(", "self", ",", "db_uri", ",", "db_name", ",", "collection_name", ")", ":", "if", "not", "self", ".", "_check_indexes", "or", "db_uri", "is", "None", ":", "return", "{", "'indexes'", ":", "None", "}", "if", "db_name", "not",...
Adds a collections index entries to the cache if not present
[ "Adds", "a", "collections", "index", "entries", "to", "the", "cache", "if", "not", "present" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/analyzer.py#L91-L112
mongolab/dex
dex/analyzer.py
QueryAnalyzer._generate_query_analysis
def _generate_query_analysis(self, parsed_query, db_name, collection_name): """Translates a raw query object into a Dex query analysis""" analyzed_fields = [] field_count = 0 supported = True sort_fields = [] query_mask = None if 'command' in parsed_query and pa...
python
def _generate_query_analysis(self, parsed_query, db_name, collection_name): """Translates a raw query object into a Dex query analysis""" analyzed_fields = [] field_count = 0 supported = True sort_fields = [] query_mask = None if 'command' in parsed_query and pa...
[ "def", "_generate_query_analysis", "(", "self", ",", "parsed_query", ",", "db_name", ",", "collection_name", ")", ":", "analyzed_fields", "=", "[", "]", "field_count", "=", "0", "supported", "=", "True", "sort_fields", "=", "[", "]", "query_mask", "=", "None",...
Translates a raw query object into a Dex query analysis
[ "Translates", "a", "raw", "query", "object", "into", "a", "Dex", "query", "analysis" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/analyzer.py#L115-L177
mongolab/dex
dex/analyzer.py
QueryAnalyzer._generate_index_analysis
def _generate_index_analysis(self, query_analysis, indexes): """Compares a query signature to the index cache to identify complete and partial indexes available to the query""" needs_recommendation = True full_indexes = [] partial_indexes = [] coverage = "unknown" ...
python
def _generate_index_analysis(self, query_analysis, indexes): """Compares a query signature to the index cache to identify complete and partial indexes available to the query""" needs_recommendation = True full_indexes = [] partial_indexes = [] coverage = "unknown" ...
[ "def", "_generate_index_analysis", "(", "self", ",", "query_analysis", ",", "indexes", ")", ":", "needs_recommendation", "=", "True", "full_indexes", "=", "[", "]", "partial_indexes", "=", "[", "]", "coverage", "=", "\"unknown\"", "if", "indexes", "is", "not", ...
Compares a query signature to the index cache to identify complete and partial indexes available to the query
[ "Compares", "a", "query", "signature", "to", "the", "index", "cache", "to", "identify", "complete", "and", "partial", "indexes", "available", "to", "the", "query" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/analyzer.py#L180-L211
mongolab/dex
dex/analyzer.py
QueryAnalyzer._generate_index_report
def _generate_index_report(self, index, query_analysis): """Analyzes an existing index against the results of query analysis""" all_fields = [] equiv_fields = [] sort_fields = [] range_fields = [] for query_field in query_analysis['analyzedFields']: all_fiel...
python
def _generate_index_report(self, index, query_analysis): """Analyzes an existing index against the results of query analysis""" all_fields = [] equiv_fields = [] sort_fields = [] range_fields = [] for query_field in query_analysis['analyzedFields']: all_fiel...
[ "def", "_generate_index_report", "(", "self", ",", "index", ",", "query_analysis", ")", ":", "all_fields", "=", "[", "]", "equiv_fields", "=", "[", "]", "sort_fields", "=", "[", "]", "range_fields", "=", "[", "]", "for", "query_field", "in", "query_analysis"...
Analyzes an existing index against the results of query analysis
[ "Analyzes", "an", "existing", "index", "against", "the", "results", "of", "query", "analysis" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/analyzer.py#L214-L273
mongolab/dex
dex/analyzer.py
QueryAnalyzer._generate_recommendation
def _generate_recommendation(self, query_analysis, db_name, collection_name): """Generates an ideal query recommendation""" index_rec = '{' for query_field in query_analysis['analyzedFields']: ...
python
def _generate_recommendation(self, query_analysis, db_name, collection_name): """Generates an ideal query recommendation""" index_rec = '{' for query_field in query_analysis['analyzedFields']: ...
[ "def", "_generate_recommendation", "(", "self", ",", "query_analysis", ",", "db_name", ",", "collection_name", ")", ":", "index_rec", "=", "'{'", "for", "query_field", "in", "query_analysis", "[", "'analyzedFields'", "]", ":", "if", "query_field", "[", "'fieldType...
Generates an ideal query recommendation
[ "Generates", "an", "ideal", "query", "recommendation" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/analyzer.py#L276-L301
mongolab/dex
dex/analyzer.py
ReportAggregation.add_query_occurrence
def add_query_occurrence(self, report): """Adds a report to the report aggregation""" initial_millis = int(report['parsed']['stats']['millis']) mask = report['queryMask'] existing_report = self._get_existing_report(mask, report) if existing_report is not None: self...
python
def add_query_occurrence(self, report): """Adds a report to the report aggregation""" initial_millis = int(report['parsed']['stats']['millis']) mask = report['queryMask'] existing_report = self._get_existing_report(mask, report) if existing_report is not None: self...
[ "def", "add_query_occurrence", "(", "self", ",", "report", ")", ":", "initial_millis", "=", "int", "(", "report", "[", "'parsed'", "]", "[", "'stats'", "]", "[", "'millis'", "]", ")", "mask", "=", "report", "[", "'queryMask'", "]", "existing_report", "=", ...
Adds a report to the report aggregation
[ "Adds", "a", "report", "to", "the", "report", "aggregation" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/analyzer.py#L327-L350
mongolab/dex
dex/analyzer.py
ReportAggregation.get_reports
def get_reports(self): """Returns a minimized version of the aggregation""" return sorted(self._reports, key=lambda x: x['stats']['totalTimeMillis'], reverse=True)
python
def get_reports(self): """Returns a minimized version of the aggregation""" return sorted(self._reports, key=lambda x: x['stats']['totalTimeMillis'], reverse=True)
[ "def", "get_reports", "(", "self", ")", ":", "return", "sorted", "(", "self", ".", "_reports", ",", "key", "=", "lambda", "x", ":", "x", "[", "'stats'", "]", "[", "'totalTimeMillis'", "]", ",", "reverse", "=", "True", ")" ]
Returns a minimized version of the aggregation
[ "Returns", "a", "minimized", "version", "of", "the", "aggregation" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/analyzer.py#L353-L357
mongolab/dex
dex/analyzer.py
ReportAggregation._get_existing_report
def _get_existing_report(self, mask, report): """Returns the aggregated report that matches report""" for existing_report in self._reports: if existing_report['namespace'] == report['namespace']: if mask == existing_report['queryMask']: return existing_rep...
python
def _get_existing_report(self, mask, report): """Returns the aggregated report that matches report""" for existing_report in self._reports: if existing_report['namespace'] == report['namespace']: if mask == existing_report['queryMask']: return existing_rep...
[ "def", "_get_existing_report", "(", "self", ",", "mask", ",", "report", ")", ":", "for", "existing_report", "in", "self", ".", "_reports", ":", "if", "existing_report", "[", "'namespace'", "]", "==", "report", "[", "'namespace'", "]", ":", "if", "mask", "=...
Returns the aggregated report that matches report
[ "Returns", "the", "aggregated", "report", "that", "matches", "report" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/analyzer.py#L360-L366
mongolab/dex
dex/analyzer.py
ReportAggregation._merge_report
def _merge_report(self, target, new): """Merges a new report into the target report""" time = None if 'ts' in new['parsed']: time = new['parsed']['ts'] if (target.get('lastSeenDate', None) and time and target['lastSeenDate'] < time): ...
python
def _merge_report(self, target, new): """Merges a new report into the target report""" time = None if 'ts' in new['parsed']: time = new['parsed']['ts'] if (target.get('lastSeenDate', None) and time and target['lastSeenDate'] < time): ...
[ "def", "_merge_report", "(", "self", ",", "target", ",", "new", ")", ":", "time", "=", "None", "if", "'ts'", "in", "new", "[", "'parsed'", "]", ":", "time", "=", "new", "[", "'parsed'", "]", "[", "'ts'", "]", "if", "(", "target", ".", "get", "(",...
Merges a new report into the target report
[ "Merges", "a", "new", "report", "into", "the", "target", "report" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/analyzer.py#L369-L383
mongolab/dex
dex/parsers.py
Parser.parse
def parse(self, input): """Passes input to each QueryLineHandler in use""" query = None for handler in self._line_handlers: try: query = handler.handle(input) except Exception as e: query = None finally: if query...
python
def parse(self, input): """Passes input to each QueryLineHandler in use""" query = None for handler in self._line_handlers: try: query = handler.handle(input) except Exception as e: query = None finally: if query...
[ "def", "parse", "(", "self", ",", "input", ")", ":", "query", "=", "None", "for", "handler", "in", "self", ".", "_line_handlers", ":", "try", ":", "query", "=", "handler", ".", "handle", "(", "input", ")", "except", "Exception", "as", "e", ":", "quer...
Passes input to each QueryLineHandler in use
[ "Passes", "input", "to", "each", "QueryLineHandler", "in", "use" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/parsers.py#L67-L78
mongolab/dex
dex/dex.py
Dex.generate_query_report
def generate_query_report(self, db_uri, query, db_name, collection_name): """Analyzes a single query""" return self._query_analyzer.generate_query_report(db_uri, query, db_name, ...
python
def generate_query_report(self, db_uri, query, db_name, collection_name): """Analyzes a single query""" return self._query_analyzer.generate_query_report(db_uri, query, db_name, ...
[ "def", "generate_query_report", "(", "self", ",", "db_uri", ",", "query", ",", "db_name", ",", "collection_name", ")", ":", "return", "self", ".", "_query_analyzer", ".", "generate_query_report", "(", "db_uri", ",", "query", ",", "db_name", ",", "collection_name...
Analyzes a single query
[ "Analyzes", "a", "single", "query" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/dex.py#L77-L82
mongolab/dex
dex/dex.py
Dex.analyze_profile
def analyze_profile(self): """Analyzes queries from a given log file""" profile_parser = ProfileParser() databases = self._get_requested_databases() connection = pymongo.MongoClient(self._db_uri, document_class=OrderedDict, ...
python
def analyze_profile(self): """Analyzes queries from a given log file""" profile_parser = ProfileParser() databases = self._get_requested_databases() connection = pymongo.MongoClient(self._db_uri, document_class=OrderedDict, ...
[ "def", "analyze_profile", "(", "self", ")", ":", "profile_parser", "=", "ProfileParser", "(", ")", "databases", "=", "self", ".", "_get_requested_databases", "(", ")", "connection", "=", "pymongo", ".", "MongoClient", "(", "self", ".", "_db_uri", ",", "documen...
Analyzes queries from a given log file
[ "Analyzes", "queries", "from", "a", "given", "log", "file" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/dex.py#L132-L166
mongolab/dex
dex/dex.py
Dex.watch_profile
def watch_profile(self): """Analyzes queries from a given log file""" profile_parser = ProfileParser() databases = self._get_requested_databases() connection = pymongo.MongoClient(self._db_uri, document_class=OrderedDict, ...
python
def watch_profile(self): """Analyzes queries from a given log file""" profile_parser = ProfileParser() databases = self._get_requested_databases() connection = pymongo.MongoClient(self._db_uri, document_class=OrderedDict, ...
[ "def", "watch_profile", "(", "self", ")", ":", "profile_parser", "=", "ProfileParser", "(", ")", "databases", "=", "self", ".", "_get_requested_databases", "(", ")", "connection", "=", "pymongo", ".", "MongoClient", "(", "self", ".", "_db_uri", ",", "document_...
Analyzes queries from a given log file
[ "Analyzes", "queries", "from", "a", "given", "log", "file" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/dex.py#L169-L228
mongolab/dex
dex/dex.py
Dex.analyze_logfile
def analyze_logfile(self, logfile_path): self._run_stats['logSource'] = logfile_path """Analyzes queries from a given log file""" with open(logfile_path) as obj: self.analyze_logfile_object(obj) self._output_aggregated_report(sys.stdout) return 0
python
def analyze_logfile(self, logfile_path): self._run_stats['logSource'] = logfile_path """Analyzes queries from a given log file""" with open(logfile_path) as obj: self.analyze_logfile_object(obj) self._output_aggregated_report(sys.stdout) return 0
[ "def", "analyze_logfile", "(", "self", ",", "logfile_path", ")", ":", "self", ".", "_run_stats", "[", "'logSource'", "]", "=", "logfile_path", "with", "open", "(", "logfile_path", ")", "as", "obj", ":", "self", ".", "analyze_logfile_object", "(", "obj", ")",...
Analyzes queries from a given log file
[ "Analyzes", "queries", "from", "a", "given", "log", "file" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/dex.py#L231-L239
mongolab/dex
dex/dex.py
Dex.analyze_logfile_object
def analyze_logfile_object(self, file_object): """Analyzes queries from a given log file""" log_parser = LogParser() if self._start_time is None: self._start_time = datetime.now() if self._timeout != 0: self._end_time = self._start_time + timedelta(minute...
python
def analyze_logfile_object(self, file_object): """Analyzes queries from a given log file""" log_parser = LogParser() if self._start_time is None: self._start_time = datetime.now() if self._timeout != 0: self._end_time = self._start_time + timedelta(minute...
[ "def", "analyze_logfile_object", "(", "self", ",", "file_object", ")", ":", "log_parser", "=", "LogParser", "(", ")", "if", "self", ".", "_start_time", "is", "None", ":", "self", ".", "_start_time", "=", "datetime", ".", "now", "(", ")", "if", "self", "....
Analyzes queries from a given log file
[ "Analyzes", "queries", "from", "a", "given", "log", "file" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/dex.py#L242-L261
mongolab/dex
dex/dex.py
Dex.watch_logfile
def watch_logfile(self, logfile_path): """Analyzes queries from the tail of a given log file""" self._run_stats['logSource'] = logfile_path log_parser = LogParser() # For each new line in the logfile ... output_time = time.time() + WATCH_DISPLAY_REFRESH_SECONDS try: ...
python
def watch_logfile(self, logfile_path): """Analyzes queries from the tail of a given log file""" self._run_stats['logSource'] = logfile_path log_parser = LogParser() # For each new line in the logfile ... output_time = time.time() + WATCH_DISPLAY_REFRESH_SECONDS try: ...
[ "def", "watch_logfile", "(", "self", ",", "logfile_path", ")", ":", "self", ".", "_run_stats", "[", "'logSource'", "]", "=", "logfile_path", "log_parser", "=", "LogParser", "(", ")", "# For each new line in the logfile ...", "output_time", "=", "time", ".", "time"...
Analyzes queries from the tail of a given log file
[ "Analyzes", "queries", "from", "the", "tail", "of", "a", "given", "log", "file" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/dex.py#L264-L287
mongolab/dex
dex/dex.py
Dex._tail_file
def _tail_file(self, file, interval): """Tails a file""" file.seek(0,2) while True: where = file.tell() line = file.readline() if not line: time.sleep(interval) file.seek(where) else: yield line
python
def _tail_file(self, file, interval): """Tails a file""" file.seek(0,2) while True: where = file.tell() line = file.readline() if not line: time.sleep(interval) file.seek(where) else: yield line
[ "def", "_tail_file", "(", "self", ",", "file", ",", "interval", ")", ":", "file", ".", "seek", "(", "0", ",", "2", ")", "while", "True", ":", "where", "=", "file", ".", "tell", "(", ")", "line", "=", "file", ".", "readline", "(", ")", "if", "no...
Tails a file
[ "Tails", "a", "file" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/dex.py#L316-L326
mongolab/dex
dex/dex.py
Dex._tail_profile
def _tail_profile(self, db, interval): """Tails the system.profile collection""" latest_doc = None while latest_doc is None: time.sleep(interval) latest_doc = db['system.profile'].find_one() current_time = latest_doc['ts'] while True: time.sl...
python
def _tail_profile(self, db, interval): """Tails the system.profile collection""" latest_doc = None while latest_doc is None: time.sleep(interval) latest_doc = db['system.profile'].find_one() current_time = latest_doc['ts'] while True: time.sl...
[ "def", "_tail_profile", "(", "self", ",", "db", ",", "interval", ")", ":", "latest_doc", "=", "None", "while", "latest_doc", "is", "None", ":", "time", ".", "sleep", "(", "interval", ")", "latest_doc", "=", "db", "[", "'system.profile'", "]", ".", "find_...
Tails the system.profile collection
[ "Tails", "the", "system", ".", "profile", "collection" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/dex.py#L329-L343
mongolab/dex
dex/dex.py
Dex._tuplefy_namespace
def _tuplefy_namespace(self, namespace): """Converts a mongodb namespace to a db, collection tuple""" namespace_split = namespace.split('.', 1) if len(namespace_split) is 1: # we treat a single element as a collection name. # this also properly tuplefies '*' n...
python
def _tuplefy_namespace(self, namespace): """Converts a mongodb namespace to a db, collection tuple""" namespace_split = namespace.split('.', 1) if len(namespace_split) is 1: # we treat a single element as a collection name. # this also properly tuplefies '*' n...
[ "def", "_tuplefy_namespace", "(", "self", ",", "namespace", ")", ":", "namespace_split", "=", "namespace", ".", "split", "(", "'.'", ",", "1", ")", "if", "len", "(", "namespace_split", ")", "is", "1", ":", "# we treat a single element as a collection name.", "# ...
Converts a mongodb namespace to a db, collection tuple
[ "Converts", "a", "mongodb", "namespace", "to", "a", "db", "collection", "tuple" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/dex.py#L347-L358
mongolab/dex
dex/dex.py
Dex._validate_namespaces
def _validate_namespaces(self, input_namespaces): """Converts a list of db namespaces to a list of namespace tuples, supporting basic commandline wildcards""" output_namespaces = [] if input_namespaces == []: return output_namespaces elif '*' in input_namespaces: ...
python
def _validate_namespaces(self, input_namespaces): """Converts a list of db namespaces to a list of namespace tuples, supporting basic commandline wildcards""" output_namespaces = [] if input_namespaces == []: return output_namespaces elif '*' in input_namespaces: ...
[ "def", "_validate_namespaces", "(", "self", ",", "input_namespaces", ")", ":", "output_namespaces", "=", "[", "]", "if", "input_namespaces", "==", "[", "]", ":", "return", "output_namespaces", "elif", "'*'", "in", "input_namespaces", ":", "if", "len", "(", "in...
Converts a list of db namespaces to a list of namespace tuples, supporting basic commandline wildcards
[ "Converts", "a", "list", "of", "db", "namespaces", "to", "a", "list", "of", "namespace", "tuples", "supporting", "basic", "commandline", "wildcards" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/dex.py#L362-L390
mongolab/dex
dex/dex.py
Dex._namespace_requested
def _namespace_requested(self, namespace): """Checks whether the requested_namespaces contain the provided namespace""" if namespace is None: return False namespace_tuple = self._tuplefy_namespace(namespace) if namespace_tuple[0] in IGNORE_DBS: return ...
python
def _namespace_requested(self, namespace): """Checks whether the requested_namespaces contain the provided namespace""" if namespace is None: return False namespace_tuple = self._tuplefy_namespace(namespace) if namespace_tuple[0] in IGNORE_DBS: return ...
[ "def", "_namespace_requested", "(", "self", ",", "namespace", ")", ":", "if", "namespace", "is", "None", ":", "return", "False", "namespace_tuple", "=", "self", ".", "_tuplefy_namespace", "(", "namespace", ")", "if", "namespace_tuple", "[", "0", "]", "in", "...
Checks whether the requested_namespaces contain the provided namespace
[ "Checks", "whether", "the", "requested_namespaces", "contain", "the", "provided", "namespace" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/dex.py#L393-L404
mongolab/dex
dex/dex.py
Dex._tuple_requested
def _tuple_requested(self, namespace_tuple): """Helper for _namespace_requested. Supports limited wildcards""" if not isinstance(namespace_tuple[0], unicode): encoded_db = unicode(namespace_tuple[0]) else: encoded_db = namespace_tuple[0] if not isinstance(namespac...
python
def _tuple_requested(self, namespace_tuple): """Helper for _namespace_requested. Supports limited wildcards""" if not isinstance(namespace_tuple[0], unicode): encoded_db = unicode(namespace_tuple[0]) else: encoded_db = namespace_tuple[0] if not isinstance(namespac...
[ "def", "_tuple_requested", "(", "self", ",", "namespace_tuple", ")", ":", "if", "not", "isinstance", "(", "namespace_tuple", "[", "0", "]", ",", "unicode", ")", ":", "encoded_db", "=", "unicode", "(", "namespace_tuple", "[", "0", "]", ")", "else", ":", "...
Helper for _namespace_requested. Supports limited wildcards
[ "Helper", "for", "_namespace_requested", ".", "Supports", "limited", "wildcards" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/dex.py#L407-L428
mongolab/dex
dex/dex.py
Dex._get_requested_databases
def _get_requested_databases(self): """Returns a list of databases requested, not including ignored dbs""" requested_databases = [] if ((self._requested_namespaces is not None) and (self._requested_namespaces != [])): for requested_namespace in self._requested_namespa...
python
def _get_requested_databases(self): """Returns a list of databases requested, not including ignored dbs""" requested_databases = [] if ((self._requested_namespaces is not None) and (self._requested_namespaces != [])): for requested_namespace in self._requested_namespa...
[ "def", "_get_requested_databases", "(", "self", ")", ":", "requested_databases", "=", "[", "]", "if", "(", "(", "self", ".", "_requested_namespaces", "is", "not", "None", ")", "and", "(", "self", ".", "_requested_namespaces", "!=", "[", "]", ")", ")", ":",...
Returns a list of databases requested, not including ignored dbs
[ "Returns", "a", "list", "of", "databases", "requested", "not", "including", "ignored", "dbs" ]
train
https://github.com/mongolab/dex/blob/f6dc27321028ef1ffdb3d4b1165fdcce7c8f20aa/dex/dex.py#L431-L441
rakanalh/pocket-api
pocket/__init__.py
Pocket.retrieve
def retrieve(self, state=None, favorite=None, tag=None, contentType=None, sort=None, detailType=None, search=None, domain=None, since=None, count=None, offset=None): """ Retrieve the list of your articles See: https://getpocket.com/developer/docs/v3/retrieve ...
python
def retrieve(self, state=None, favorite=None, tag=None, contentType=None, sort=None, detailType=None, search=None, domain=None, since=None, count=None, offset=None): """ Retrieve the list of your articles See: https://getpocket.com/developer/docs/v3/retrieve ...
[ "def", "retrieve", "(", "self", ",", "state", "=", "None", ",", "favorite", "=", "None", ",", "tag", "=", "None", ",", "contentType", "=", "None", ",", "sort", "=", "None", ",", "detailType", "=", "None", ",", "search", "=", "None", ",", "domain", ...
Retrieve the list of your articles See: https://getpocket.com/developer/docs/v3/retrieve :param state: filter by state :param favorite: only fetch favorite :param tag: filter by tag or _untagged_ :param contentType: get article, video or image :param sort: sort by provide...
[ "Retrieve", "the", "list", "of", "your", "articles", "See", ":", "https", ":", "//", "getpocket", ".", "com", "/", "developer", "/", "docs", "/", "v3", "/", "retrieve", ":", "param", "state", ":", "filter", "by", "state", ":", "param", "favorite", ":",...
train
https://github.com/rakanalh/pocket-api/blob/d8222dd34e3aa5e545f9b8ba407fa277c734ab82/pocket/__init__.py#L39-L59
rakanalh/pocket-api
pocket/__init__.py
Pocket.bulk_add
def bulk_add(self, item_id, ref_id=None, tags=None, time=None, title=None, url=None): """ Add an item to list See: https://getpocket.com/developer/docs/v3/modify :param item_id: int :param ref_id: tweet_id :param tags: list of tags :param time: ti...
python
def bulk_add(self, item_id, ref_id=None, tags=None, time=None, title=None, url=None): """ Add an item to list See: https://getpocket.com/developer/docs/v3/modify :param item_id: int :param ref_id: tweet_id :param tags: list of tags :param time: ti...
[ "def", "bulk_add", "(", "self", ",", "item_id", ",", "ref_id", "=", "None", ",", "tags", "=", "None", ",", "time", "=", "None", ",", "title", "=", "None", ",", "url", "=", "None", ")", ":", "self", ".", "_add_action", "(", "'add'", ")", "return", ...
Add an item to list See: https://getpocket.com/developer/docs/v3/modify :param item_id: int :param ref_id: tweet_id :param tags: list of tags :param time: time of action :param title: given title :param url: item url :return: self for chaining :rty...
[ "Add", "an", "item", "to", "list", "See", ":", "https", ":", "//", "getpocket", ".", "com", "/", "developer", "/", "docs", "/", "v3", "/", "modify", ":", "param", "item_id", ":", "int", ":", "param", "ref_id", ":", "tweet_id", ":", "param", "tags", ...
train
https://github.com/rakanalh/pocket-api/blob/d8222dd34e3aa5e545f9b8ba407fa277c734ab82/pocket/__init__.py#L61-L76
rakanalh/pocket-api
pocket/__init__.py
Pocket._add_action
def _add_action(self, action): """ Register an action into bulk :param action: action name """ kwargs = self._get_method_params() kwargs['action'] = action self._bulk_actions.append(kwargs)
python
def _add_action(self, action): """ Register an action into bulk :param action: action name """ kwargs = self._get_method_params() kwargs['action'] = action self._bulk_actions.append(kwargs)
[ "def", "_add_action", "(", "self", ",", "action", ")", ":", "kwargs", "=", "self", ".", "_get_method_params", "(", ")", "kwargs", "[", "'action'", "]", "=", "action", "self", ".", "_bulk_actions", ".", "append", "(", "kwargs", ")" ]
Register an action into bulk :param action: action name
[ "Register", "an", "action", "into", "bulk", ":", "param", "action", ":", "action", "name" ]
train
https://github.com/rakanalh/pocket-api/blob/d8222dd34e3aa5e545f9b8ba407fa277c734ab82/pocket/__init__.py#L251-L260
rakanalh/pocket-api
pocket/__init__.py
Pocket._make_request
def _make_request(self, action): """ Perform the request :param action: action name :return: a dict containing the request result :rtype: dict """ if isinstance(action, list): kwargs = {'actions': action} action = 'send' else: ...
python
def _make_request(self, action): """ Perform the request :param action: action name :return: a dict containing the request result :rtype: dict """ if isinstance(action, list): kwargs = {'actions': action} action = 'send' else: ...
[ "def", "_make_request", "(", "self", ",", "action", ")", ":", "if", "isinstance", "(", "action", ",", "list", ")", ":", "kwargs", "=", "{", "'actions'", ":", "action", "}", "action", "=", "'send'", "else", ":", "kwargs", "=", "self", ".", "_get_method_...
Perform the request :param action: action name :return: a dict containing the request result :rtype: dict
[ "Perform", "the", "request", ":", "param", "action", ":", "action", "name", ":", "return", ":", "a", "dict", "containing", "the", "request", "result", ":", "rtype", ":", "dict" ]
train
https://github.com/rakanalh/pocket-api/blob/d8222dd34e3aa5e545f9b8ba407fa277c734ab82/pocket/__init__.py#L262-L289
rakanalh/pocket-api
pocket/__init__.py
Pocket._get_method_params
def _get_method_params(self): """ This method makes reading and filtering each method implemented in this class a more general approach. It reads the previous frame from Python and filters the params passed to the caller of _make_request. :return: a dictionary of caller's...
python
def _get_method_params(self): """ This method makes reading and filtering each method implemented in this class a more general approach. It reads the previous frame from Python and filters the params passed to the caller of _make_request. :return: a dictionary of caller's...
[ "def", "_get_method_params", "(", "self", ")", ":", "caller", "=", "sys", ".", "_getframe", "(", "2", ")", "var_names", "=", "list", "(", "caller", ".", "f_code", ".", "co_varnames", ")", "caller_locals", "=", "caller", ".", "f_locals", "var_names", ".", ...
This method makes reading and filtering each method implemented in this class a more general approach. It reads the previous frame from Python and filters the params passed to the caller of _make_request. :return: a dictionary of caller's parameters and values :rtype: dict
[ "This", "method", "makes", "reading", "and", "filtering", "each", "method", "implemented", "in", "this", "class", "a", "more", "general", "approach", ".", "It", "reads", "the", "previous", "frame", "from", "Python", "and", "filters", "the", "params", "passed",...
train
https://github.com/rakanalh/pocket-api/blob/d8222dd34e3aa5e545f9b8ba407fa277c734ab82/pocket/__init__.py#L291-L307
rakanalh/pocket-api
pocket/__init__.py
Pocket._make_exception
def _make_exception(self, response): """ In case of exception, construct the exception object that holds all important values returned by the response. :return: The exception instance :rtype: PocketException """ headers = response.headers limit_he...
python
def _make_exception(self, response): """ In case of exception, construct the exception object that holds all important values returned by the response. :return: The exception instance :rtype: PocketException """ headers = response.headers limit_he...
[ "def", "_make_exception", "(", "self", ",", "response", ")", ":", "headers", "=", "response", ".", "headers", "limit_headers", "=", "[", "]", "if", "'X-Limit-User-Limit'", "in", "headers", ":", "limit_headers", "=", "[", "headers", "[", "'X-Limit-User-Limit'", ...
In case of exception, construct the exception object that holds all important values returned by the response. :return: The exception instance :rtype: PocketException
[ "In", "case", "of", "exception", "construct", "the", "exception", "object", "that", "holds", "all", "important", "values", "returned", "by", "the", "response", ".", ":", "return", ":", "The", "exception", "instance", ":", "rtype", ":", "PocketException" ]
train
https://github.com/rakanalh/pocket-api/blob/d8222dd34e3aa5e545f9b8ba407fa277c734ab82/pocket/__init__.py#L329-L360
Alir3z4/python-currencies
currencies/__init__.py
Currency.set_money_currency
def set_money_currency(self, money_currency): """ :type money_currency: str """ if money_currency not in self.money_formats: raise CurrencyDoesNotExist self.money_currency = money_currency
python
def set_money_currency(self, money_currency): """ :type money_currency: str """ if money_currency not in self.money_formats: raise CurrencyDoesNotExist self.money_currency = money_currency
[ "def", "set_money_currency", "(", "self", ",", "money_currency", ")", ":", "if", "money_currency", "not", "in", "self", ".", "money_formats", ":", "raise", "CurrencyDoesNotExist", "self", ".", "money_currency", "=", "money_currency" ]
:type money_currency: str
[ ":", "type", "money_currency", ":", "str" ]
train
https://github.com/Alir3z4/python-currencies/blob/f8790c4da5df405bd23c63c0d2b02a417424d835/currencies/__init__.py#L26-L33
Alir3z4/python-currencies
currencies/__init__.py
Currency.get_money_format
def get_money_format(self, amount): """ :type amount: int or float or str Usage: >>> currency = Currency('USD') >>> currency.get_money_format(13) >>> '$13' >>> currency.get_money_format(13.99) >>> '$13.99' >>> currency.get_money_format('13,2313,33...
python
def get_money_format(self, amount): """ :type amount: int or float or str Usage: >>> currency = Currency('USD') >>> currency.get_money_format(13) >>> '$13' >>> currency.get_money_format(13.99) >>> '$13.99' >>> currency.get_money_format('13,2313,33...
[ "def", "get_money_format", "(", "self", ",", "amount", ")", ":", "return", "self", ".", "money_formats", "[", "self", ".", "get_money_currency", "(", ")", "]", "[", "'money_format'", "]", ".", "format", "(", "amount", "=", "amount", ")" ]
:type amount: int or float or str Usage: >>> currency = Currency('USD') >>> currency.get_money_format(13) >>> '$13' >>> currency.get_money_format(13.99) >>> '$13.99' >>> currency.get_money_format('13,2313,33') >>> '$13,2313,33' :rtype: str
[ ":", "type", "amount", ":", "int", "or", "float", "or", "str" ]
train
https://github.com/Alir3z4/python-currencies/blob/f8790c4da5df405bd23c63c0d2b02a417424d835/currencies/__init__.py#L48-L65