repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
python-fedex-devs/python-fedex
fedex/base_service.py
FedexBaseService._check_response_for_request_errors
def _check_response_for_request_errors(self): """ Override this in each service module to check for errors that are specific to that module. For example, invalid tracking numbers in a Tracking request. """ if self.response.HighestSeverity == "ERROR": for noti...
python
def _check_response_for_request_errors(self): """ Override this in each service module to check for errors that are specific to that module. For example, invalid tracking numbers in a Tracking request. """ if self.response.HighestSeverity == "ERROR": for noti...
[ "def", "_check_response_for_request_errors", "(", "self", ")", ":", "if", "self", ".", "response", ".", "HighestSeverity", "==", "\"ERROR\"", ":", "for", "notification", "in", "self", ".", "response", ".", "Notifications", ":", "if", "notification", ".", "Severi...
Override this in each service module to check for errors that are specific to that module. For example, invalid tracking numbers in a Tracking request.
[ "Override", "this", "in", "each", "service", "module", "to", "check", "for", "errors", "that", "are", "specific", "to", "that", "module", ".", "For", "example", "invalid", "tracking", "numbers", "in", "a", "Tracking", "request", "." ]
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/base_service.py#L254-L265
python-fedex-devs/python-fedex
fedex/base_service.py
FedexBaseService._check_response_for_request_warnings
def _check_response_for_request_warnings(self): """ Override this in a service module to check for errors that are specific to that module. For example, changing state/province based on postal code in a Rate Service request. """ if self.response.HighestSeverity in ("NOTE...
python
def _check_response_for_request_warnings(self): """ Override this in a service module to check for errors that are specific to that module. For example, changing state/province based on postal code in a Rate Service request. """ if self.response.HighestSeverity in ("NOTE...
[ "def", "_check_response_for_request_warnings", "(", "self", ")", ":", "if", "self", ".", "response", ".", "HighestSeverity", "in", "(", "\"NOTE\"", ",", "\"WARNING\"", ")", ":", "for", "notification", "in", "self", ".", "response", ".", "Notifications", ":", "...
Override this in a service module to check for errors that are specific to that module. For example, changing state/province based on postal code in a Rate Service request.
[ "Override", "this", "in", "a", "service", "module", "to", "check", "for", "errors", "that", "are", "specific", "to", "that", "module", ".", "For", "example", "changing", "state", "/", "province", "based", "on", "postal", "code", "in", "a", "Rate", "Service...
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/base_service.py#L267-L278
python-fedex-devs/python-fedex
fedex/base_service.py
FedexBaseService.send_request
def send_request(self, send_function=None): """ Sends the assembled request on the child object. @type send_function: function reference @keyword send_function: A function reference (passed without the parenthesis) to a function that will send the request. This al...
python
def send_request(self, send_function=None): """ Sends the assembled request on the child object. @type send_function: function reference @keyword send_function: A function reference (passed without the parenthesis) to a function that will send the request. This al...
[ "def", "send_request", "(", "self", ",", "send_function", "=", "None", ")", ":", "# Send the request and get the response back.", "try", ":", "# If the user has overridden the send function, use theirs", "# instead of the default.", "if", "send_function", ":", "# Follow the overr...
Sends the assembled request on the child object. @type send_function: function reference @keyword send_function: A function reference (passed without the parenthesis) to a function that will send the request. This allows for overriding the default function in cases such as ...
[ "Sends", "the", "assembled", "request", "on", "the", "child", "object", "." ]
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/base_service.py#L299-L339
python-fedex-devs/python-fedex
fedex/services/address_validation_service.py
FedexAddressValidationRequest._assemble_and_send_request
def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. """ # We get an exception like this when specifying an IntegratorId: ...
python
def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. """ # We get an exception like this when specifying an IntegratorId: ...
[ "def", "_assemble_and_send_request", "(", "self", ")", ":", "# We get an exception like this when specifying an IntegratorId:", "# suds.TypeNotFound: Type not found: 'IntegratorId'", "# Setting it to None does not seem to appease it.", "del", "self", ".", "ClientDetail", ".", "Integrator...
Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED.
[ "Fires", "off", "the", "Fedex", "request", "." ]
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/services/address_validation_service.py#L48-L71
python-fedex-devs/python-fedex
fedex/services/track_service.py
FedexTrackRequest._prepare_wsdl_objects
def _prepare_wsdl_objects(self): """ This sets the package identifier information. This may be a tracking number or a few different things as per the Fedex spec. """ self.SelectionDetails = self.client.factory.create('TrackSelectionDetail') # Default to Fedex se...
python
def _prepare_wsdl_objects(self): """ This sets the package identifier information. This may be a tracking number or a few different things as per the Fedex spec. """ self.SelectionDetails = self.client.factory.create('TrackSelectionDetail') # Default to Fedex se...
[ "def", "_prepare_wsdl_objects", "(", "self", ")", ":", "self", ".", "SelectionDetails", "=", "self", ".", "client", ".", "factory", ".", "create", "(", "'TrackSelectionDetail'", ")", "# Default to Fedex", "self", ".", "SelectionDetails", ".", "CarrierCode", "=", ...
This sets the package identifier information. This may be a tracking number or a few different things as per the Fedex spec.
[ "This", "sets", "the", "package", "identifier", "information", ".", "This", "may", "be", "a", "tracking", "number", "or", "a", "few", "different", "things", "as", "per", "the", "Fedex", "spec", "." ]
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/services/track_service.py#L60-L76
python-fedex-devs/python-fedex
fedex/services/track_service.py
FedexTrackRequest._check_response_for_request_errors
def _check_response_for_request_errors(self): """ Checks the response to see if there were any errors specific to this WSDL. """ if self.response.HighestSeverity == "ERROR": # pragma: no cover for notification in self.response.Notifications: if notifi...
python
def _check_response_for_request_errors(self): """ Checks the response to see if there were any errors specific to this WSDL. """ if self.response.HighestSeverity == "ERROR": # pragma: no cover for notification in self.response.Notifications: if notifi...
[ "def", "_check_response_for_request_errors", "(", "self", ")", ":", "if", "self", ".", "response", ".", "HighestSeverity", "==", "\"ERROR\"", ":", "# pragma: no cover", "for", "notification", "in", "self", ".", "response", ".", "Notifications", ":", "if", "notific...
Checks the response to see if there were any errors specific to this WSDL.
[ "Checks", "the", "response", "to", "see", "if", "there", "were", "any", "errors", "specific", "to", "this", "WSDL", "." ]
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/services/track_service.py#L78-L90
python-fedex-devs/python-fedex
fedex/services/track_service.py
FedexTrackRequest._assemble_and_send_request
def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. """ client = self.client # Fire off the query. return c...
python
def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. """ client = self.client # Fire off the query. return c...
[ "def", "_assemble_and_send_request", "(", "self", ")", ":", "client", "=", "self", ".", "client", "# Fire off the query.", "return", "client", ".", "service", ".", "track", "(", "WebAuthenticationDetail", "=", "self", ".", "WebAuthenticationDetail", ",", "ClientDeta...
Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED.
[ "Fires", "off", "the", "Fedex", "request", "." ]
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/services/track_service.py#L92-L108
python-fedex-devs/python-fedex
fedex/services/rate_service.py
FedexRateServiceRequest._prepare_wsdl_objects
def _prepare_wsdl_objects(self): """ This is the data that will be used to create your shipment. Create the data structure and get it ready for the WSDL request. """ # Default behavior is to not request transit information self.ReturnTransitAndCommit = False # T...
python
def _prepare_wsdl_objects(self): """ This is the data that will be used to create your shipment. Create the data structure and get it ready for the WSDL request. """ # Default behavior is to not request transit information self.ReturnTransitAndCommit = False # T...
[ "def", "_prepare_wsdl_objects", "(", "self", ")", ":", "# Default behavior is to not request transit information", "self", ".", "ReturnTransitAndCommit", "=", "False", "# This is the primary data structure for processShipment requests.", "self", ".", "RequestedShipment", "=", "self...
This is the data that will be used to create your shipment. Create the data structure and get it ready for the WSDL request.
[ "This", "is", "the", "data", "that", "will", "be", "used", "to", "create", "your", "shipment", ".", "Create", "the", "data", "structure", "and", "get", "it", "ready", "for", "the", "WSDL", "request", "." ]
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/services/rate_service.py#L43-L91
python-fedex-devs/python-fedex
fedex/services/rate_service.py
FedexRateServiceRequest._assemble_and_send_request
def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. """ # Fire off the query. return self.client.service.getRates(...
python
def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. """ # Fire off the query. return self.client.service.getRates(...
[ "def", "_assemble_and_send_request", "(", "self", ")", ":", "# Fire off the query.", "return", "self", ".", "client", ".", "service", ".", "getRates", "(", "WebAuthenticationDetail", "=", "self", ".", "WebAuthenticationDetail", ",", "ClientDetail", "=", "self", ".",...
Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED.
[ "Fires", "off", "the", "Fedex", "request", "." ]
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/services/rate_service.py#L93-L108
python-fedex-devs/python-fedex
fedex/printers/unix.py
DirectDevicePrinter.print_label
def print_label(self, package_num=None): """ Prints all of a shipment's labels, or optionally just one. @type package_num: L{int} @param package_num: 0-based index of the package to print. This is only useful for shipments with more than one package. ...
python
def print_label(self, package_num=None): """ Prints all of a shipment's labels, or optionally just one. @type package_num: L{int} @param package_num: 0-based index of the package to print. This is only useful for shipments with more than one package. ...
[ "def", "print_label", "(", "self", ",", "package_num", "=", "None", ")", ":", "if", "package_num", ":", "packages", "=", "[", "self", ".", "shipment", ".", "response", ".", "CompletedShipmentDetail", ".", "CompletedPackageDetails", "[", "package_num", "]", "]"...
Prints all of a shipment's labels, or optionally just one. @type package_num: L{int} @param package_num: 0-based index of the package to print. This is only useful for shipments with more than one package.
[ "Prints", "all", "of", "a", "shipment", "s", "labels", "or", "optionally", "just", "one", "." ]
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/printers/unix.py#L31-L49
python-fedex-devs/python-fedex
fedex/printers/unix.py
DirectDevicePrinter._print_base64
def _print_base64(self, base64_data): """ Pipe the binary directly to the label printer. Works under Linux without requiring PySerial. This is not typically something you should call directly, unless you have special needs. @type base64_data: L{str} @param base64...
python
def _print_base64(self, base64_data): """ Pipe the binary directly to the label printer. Works under Linux without requiring PySerial. This is not typically something you should call directly, unless you have special needs. @type base64_data: L{str} @param base64...
[ "def", "_print_base64", "(", "self", ",", "base64_data", ")", ":", "label_file", "=", "open", "(", "self", ".", "device", ",", "\"w\"", ")", "label_file", ".", "write", "(", "base64_data", ")", "label_file", ".", "close", "(", ")" ]
Pipe the binary directly to the label printer. Works under Linux without requiring PySerial. This is not typically something you should call directly, unless you have special needs. @type base64_data: L{str} @param base64_data: The base64 encoded string for the label to print.
[ "Pipe", "the", "binary", "directly", "to", "the", "label", "printer", ".", "Works", "under", "Linux", "without", "requiring", "PySerial", ".", "This", "is", "not", "typically", "something", "you", "should", "call", "directly", "unless", "you", "have", "special...
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/printers/unix.py#L51-L63
python-fedex-devs/python-fedex
fedex/services/location_service.py
FedexSearchLocationRequest._prepare_wsdl_objects
def _prepare_wsdl_objects(self): """ Create the data structure and get it ready for the WSDL request. """ # Service defaults for objects that are required. self.MultipleMatchesAction = 'RETURN_ALL' self.Constraints = self.create_wsdl_object_of_type('SearchLocationConstra...
python
def _prepare_wsdl_objects(self): """ Create the data structure and get it ready for the WSDL request. """ # Service defaults for objects that are required. self.MultipleMatchesAction = 'RETURN_ALL' self.Constraints = self.create_wsdl_object_of_type('SearchLocationConstra...
[ "def", "_prepare_wsdl_objects", "(", "self", ")", ":", "# Service defaults for objects that are required.", "self", ".", "MultipleMatchesAction", "=", "'RETURN_ALL'", "self", ".", "Constraints", "=", "self", ".", "create_wsdl_object_of_type", "(", "'SearchLocationConstraints'...
Create the data structure and get it ready for the WSDL request.
[ "Create", "the", "data", "structure", "and", "get", "it", "ready", "for", "the", "WSDL", "request", "." ]
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/services/location_service.py#L58-L68
python-fedex-devs/python-fedex
fedex/services/location_service.py
FedexSearchLocationRequest._assemble_and_send_request
def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. """ # We get an exception like this when specifying an IntegratorId: ...
python
def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. """ # We get an exception like this when specifying an IntegratorId: ...
[ "def", "_assemble_and_send_request", "(", "self", ")", ":", "# We get an exception like this when specifying an IntegratorId:", "# suds.TypeNotFound: Type not found: 'IntegratorId'", "# Setting it to None does not seem to appease it.", "del", "self", ".", "ClientDetail", ".", "Integrator...
Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED.
[ "Fires", "off", "the", "Fedex", "request", "." ]
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/services/location_service.py#L70-L97
python-fedex-devs/python-fedex
fedex/services/package_movement.py
PostalCodeInquiryRequest._check_response_for_request_errors
def _check_response_for_request_errors(self): """ Checks the response to see if there were any errors specific to this WSDL. """ if self.response.HighestSeverity == "ERROR": for notification in self.response.Notifications: # pragma: no cover if notifi...
python
def _check_response_for_request_errors(self): """ Checks the response to see if there were any errors specific to this WSDL. """ if self.response.HighestSeverity == "ERROR": for notification in self.response.Notifications: # pragma: no cover if notifi...
[ "def", "_check_response_for_request_errors", "(", "self", ")", ":", "if", "self", ".", "response", ".", "HighestSeverity", "==", "\"ERROR\"", ":", "for", "notification", "in", "self", ".", "response", ".", "Notifications", ":", "# pragma: no cover", "if", "notific...
Checks the response to see if there were any errors specific to this WSDL.
[ "Checks", "the", "response", "to", "see", "if", "there", "were", "any", "errors", "specific", "to", "this", "WSDL", "." ]
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/services/package_movement.py#L66-L83
python-fedex-devs/python-fedex
fedex/services/package_movement.py
PostalCodeInquiryRequest._assemble_and_send_request
def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. """ client = self.client # We get an exception like this when ...
python
def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. """ client = self.client # We get an exception like this when ...
[ "def", "_assemble_and_send_request", "(", "self", ")", ":", "client", "=", "self", ".", "client", "# We get an exception like this when specifying an IntegratorId:", "# suds.TypeNotFound: Type not found: 'IntegratorId'", "# Setting it to None does not seem to appease it.", "del", "self...
Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED.
[ "Fires", "off", "the", "Fedex", "request", "." ]
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/services/package_movement.py#L92-L117
python-fedex-devs/python-fedex
fedex/services/availability_commitment_service.py
FedexAvailabilityCommitmentRequest._prepare_wsdl_objects
def _prepare_wsdl_objects(self): """ Create the data structure and get it ready for the WSDL request. """ self.CarrierCode = 'FDXE' self.Origin = self.client.factory.create('Address') self.Destination = self.client.factory.create('Address') self.ShipDate = datetim...
python
def _prepare_wsdl_objects(self): """ Create the data structure and get it ready for the WSDL request. """ self.CarrierCode = 'FDXE' self.Origin = self.client.factory.create('Address') self.Destination = self.client.factory.create('Address') self.ShipDate = datetim...
[ "def", "_prepare_wsdl_objects", "(", "self", ")", ":", "self", ".", "CarrierCode", "=", "'FDXE'", "self", ".", "Origin", "=", "self", ".", "client", ".", "factory", ".", "create", "(", "'Address'", ")", "self", ".", "Destination", "=", "self", ".", "clie...
Create the data structure and get it ready for the WSDL request.
[ "Create", "the", "data", "structure", "and", "get", "it", "ready", "for", "the", "WSDL", "request", "." ]
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/services/availability_commitment_service.py#L63-L72
python-fedex-devs/python-fedex
fedex/services/availability_commitment_service.py
FedexAvailabilityCommitmentRequest._assemble_and_send_request
def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. """ # We get an exception like this when specifying an IntegratorId: ...
python
def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. """ # We get an exception like this when specifying an IntegratorId: ...
[ "def", "_assemble_and_send_request", "(", "self", ")", ":", "# We get an exception like this when specifying an IntegratorId:", "# suds.TypeNotFound: Type not found: 'IntegratorId'", "# Setting it to None does not seem to appease it.", "del", "self", ".", "ClientDetail", ".", "Integrator...
Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED.
[ "Fires", "off", "the", "Fedex", "request", "." ]
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/services/availability_commitment_service.py#L74-L101
python-fedex-devs/python-fedex
fedex/tools/conversion.py
basic_sobject_to_dict
def basic_sobject_to_dict(obj): """Converts suds object to dict very quickly. Does not serialize date time or normalize key case. :param obj: suds object :return: dict object """ if not hasattr(obj, '__keylist__'): return obj data = {} fields = obj.__keylist__ for field in fi...
python
def basic_sobject_to_dict(obj): """Converts suds object to dict very quickly. Does not serialize date time or normalize key case. :param obj: suds object :return: dict object """ if not hasattr(obj, '__keylist__'): return obj data = {} fields = obj.__keylist__ for field in fi...
[ "def", "basic_sobject_to_dict", "(", "obj", ")", ":", "if", "not", "hasattr", "(", "obj", ",", "'__keylist__'", ")", ":", "return", "obj", "data", "=", "{", "}", "fields", "=", "obj", ".", "__keylist__", "for", "field", "in", "fields", ":", "val", "=",...
Converts suds object to dict very quickly. Does not serialize date time or normalize key case. :param obj: suds object :return: dict object
[ "Converts", "suds", "object", "to", "dict", "very", "quickly", ".", "Does", "not", "serialize", "date", "time", "or", "normalize", "key", "case", ".", ":", "param", "obj", ":", "suds", "object", ":", "return", ":", "dict", "object" ]
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/tools/conversion.py#L33-L51
python-fedex-devs/python-fedex
fedex/tools/conversion.py
sobject_to_dict
def sobject_to_dict(obj, key_to_lower=False, json_serialize=False): """ Converts a suds object to a dict. Includes advanced features. :param json_serialize: If set, changes date and time types to iso string. :param key_to_lower: If set, changes index key name to lower case. :param obj: suds object ...
python
def sobject_to_dict(obj, key_to_lower=False, json_serialize=False): """ Converts a suds object to a dict. Includes advanced features. :param json_serialize: If set, changes date and time types to iso string. :param key_to_lower: If set, changes index key name to lower case. :param obj: suds object ...
[ "def", "sobject_to_dict", "(", "obj", ",", "key_to_lower", "=", "False", ",", "json_serialize", "=", "False", ")", ":", "import", "datetime", "if", "not", "hasattr", "(", "obj", ",", "'__keylist__'", ")", ":", "if", "json_serialize", "and", "isinstance", "("...
Converts a suds object to a dict. Includes advanced features. :param json_serialize: If set, changes date and time types to iso string. :param key_to_lower: If set, changes index key name to lower case. :param obj: suds object :return: dict object
[ "Converts", "a", "suds", "object", "to", "a", "dict", ".", "Includes", "advanced", "features", ".", ":", "param", "json_serialize", ":", "If", "set", "changes", "date", "and", "time", "types", "to", "iso", "string", ".", ":", "param", "key_to_lower", ":", ...
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/tools/conversion.py#L54-L81
python-fedex-devs/python-fedex
fedex/tools/conversion.py
sobject_to_json
def sobject_to_json(obj, key_to_lower=False): """ Converts a suds object to a JSON string. :param obj: suds object :param key_to_lower: If set, changes index key name to lower case. :return: json object """ import json data = sobject_to_dict(obj, key_to_lower=key_to_lower, json_serialize...
python
def sobject_to_json(obj, key_to_lower=False): """ Converts a suds object to a JSON string. :param obj: suds object :param key_to_lower: If set, changes index key name to lower case. :return: json object """ import json data = sobject_to_dict(obj, key_to_lower=key_to_lower, json_serialize...
[ "def", "sobject_to_json", "(", "obj", ",", "key_to_lower", "=", "False", ")", ":", "import", "json", "data", "=", "sobject_to_dict", "(", "obj", ",", "key_to_lower", "=", "key_to_lower", ",", "json_serialize", "=", "True", ")", "return", "json", ".", "dumps"...
Converts a suds object to a JSON string. :param obj: suds object :param key_to_lower: If set, changes index key name to lower case. :return: json object
[ "Converts", "a", "suds", "object", "to", "a", "JSON", "string", ".", ":", "param", "obj", ":", "suds", "object", ":", "param", "key_to_lower", ":", "If", "set", "changes", "index", "key", "name", "to", "lower", "case", ".", ":", "return", ":", "json", ...
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/tools/conversion.py#L84-L93
python-fedex-devs/python-fedex
fedex/services/country_service.py
FedexValidatePostalRequest._prepare_wsdl_objects
def _prepare_wsdl_objects(self): """ Create the data structure and get it ready for the WSDL request. """ self.CarrierCode = 'FDXE' self.RoutingCode = 'FDSD' self.Address = self.client.factory.create('Address') self.ShipDateTime = datetime.datetime.now().isoformat...
python
def _prepare_wsdl_objects(self): """ Create the data structure and get it ready for the WSDL request. """ self.CarrierCode = 'FDXE' self.RoutingCode = 'FDSD' self.Address = self.client.factory.create('Address') self.ShipDateTime = datetime.datetime.now().isoformat...
[ "def", "_prepare_wsdl_objects", "(", "self", ")", ":", "self", ".", "CarrierCode", "=", "'FDXE'", "self", ".", "RoutingCode", "=", "'FDSD'", "self", ".", "Address", "=", "self", ".", "client", ".", "factory", ".", "create", "(", "'Address'", ")", "self", ...
Create the data structure and get it ready for the WSDL request.
[ "Create", "the", "data", "structure", "and", "get", "it", "ready", "for", "the", "WSDL", "request", "." ]
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/services/country_service.py#L53-L60
python-fedex-devs/python-fedex
fedex/services/country_service.py
FedexValidatePostalRequest._assemble_and_send_request
def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. """ # We get an exception like this when specifying an IntegratorId: ...
python
def _assemble_and_send_request(self): """ Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED. """ # We get an exception like this when specifying an IntegratorId: ...
[ "def", "_assemble_and_send_request", "(", "self", ")", ":", "# We get an exception like this when specifying an IntegratorId:", "# suds.TypeNotFound: Type not found: 'IntegratorId'", "# Setting it to None does not seem to appease it.", "del", "self", ".", "ClientDetail", ".", "Integrator...
Fires off the Fedex request. @warning: NEVER CALL THIS METHOD DIRECTLY. CALL send_request(), WHICH RESIDES ON FedexBaseService AND IS INHERITED.
[ "Fires", "off", "the", "Fedex", "request", "." ]
train
https://github.com/python-fedex-devs/python-fedex/blob/7ea2ca80c362f5dbbc8d959ab47648c7a4ab24eb/fedex/services/country_service.py#L62-L88
OpenHumans/open-humans-api
ohapi/utils_fs.py
guess_tags
def guess_tags(filename): """ Function to get potential tags for files using the file names. :param filename: This field is the name of file. """ tags = [] stripped_filename = strip_zip_suffix(filename) if stripped_filename.endswith('.vcf'): tags.append('vcf') if stripped_filena...
python
def guess_tags(filename): """ Function to get potential tags for files using the file names. :param filename: This field is the name of file. """ tags = [] stripped_filename = strip_zip_suffix(filename) if stripped_filename.endswith('.vcf'): tags.append('vcf') if stripped_filena...
[ "def", "guess_tags", "(", "filename", ")", ":", "tags", "=", "[", "]", "stripped_filename", "=", "strip_zip_suffix", "(", "filename", ")", "if", "stripped_filename", ".", "endswith", "(", "'.vcf'", ")", ":", "tags", ".", "append", "(", "'vcf'", ")", "if", ...
Function to get potential tags for files using the file names. :param filename: This field is the name of file.
[ "Function", "to", "get", "potential", "tags", "for", "files", "using", "the", "file", "names", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L33-L47
OpenHumans/open-humans-api
ohapi/utils_fs.py
characterize_local_files
def characterize_local_files(filedir, max_bytes=MAX_FILE_DEFAULT): """ Collate local file info as preperation for Open Humans upload. Note: Files with filesize > max_bytes are not included in returned info. :param filedir: This field is target directory to get files from. :param max_bytes: This fi...
python
def characterize_local_files(filedir, max_bytes=MAX_FILE_DEFAULT): """ Collate local file info as preperation for Open Humans upload. Note: Files with filesize > max_bytes are not included in returned info. :param filedir: This field is target directory to get files from. :param max_bytes: This fi...
[ "def", "characterize_local_files", "(", "filedir", ",", "max_bytes", "=", "MAX_FILE_DEFAULT", ")", ":", "file_data", "=", "{", "}", "logging", ".", "info", "(", "'Characterizing files in {}'", ".", "format", "(", "filedir", ")", ")", "for", "filename", "in", "...
Collate local file info as preperation for Open Humans upload. Note: Files with filesize > max_bytes are not included in returned info. :param filedir: This field is target directory to get files from. :param max_bytes: This field is the maximum file size to consider. Its default value is 128m.
[ "Collate", "local", "file", "info", "as", "preperation", "for", "Open", "Humans", "upload", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L50-L79
OpenHumans/open-humans-api
ohapi/utils_fs.py
validate_metadata
def validate_metadata(target_dir, metadata): """ Check that the files listed in metadata exactly match files in target dir. :param target_dir: This field is the target directory from which to match metadata :param metadata: This field contains the metadata to be matched. """ if not os.p...
python
def validate_metadata(target_dir, metadata): """ Check that the files listed in metadata exactly match files in target dir. :param target_dir: This field is the target directory from which to match metadata :param metadata: This field contains the metadata to be matched. """ if not os.p...
[ "def", "validate_metadata", "(", "target_dir", ",", "metadata", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "target_dir", ")", ":", "print", "(", "\"Error: \"", "+", "target_dir", "+", "\" is not a directory\"", ")", "return", "False", "file...
Check that the files listed in metadata exactly match files in target dir. :param target_dir: This field is the target directory from which to match metadata :param metadata: This field contains the metadata to be matched.
[ "Check", "that", "the", "files", "listed", "in", "metadata", "exactly", "match", "files", "in", "target", "dir", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L82-L104
OpenHumans/open-humans-api
ohapi/utils_fs.py
load_metadata_csv_single_user
def load_metadata_csv_single_user(csv_in, header, tags_idx): """ Return the metadata as requested for a single user. :param csv_in: This field is the csv file to return metadata from. :param header: This field contains the headers in the csv file :param tags_idx: This field contains the index of th...
python
def load_metadata_csv_single_user(csv_in, header, tags_idx): """ Return the metadata as requested for a single user. :param csv_in: This field is the csv file to return metadata from. :param header: This field contains the headers in the csv file :param tags_idx: This field contains the index of th...
[ "def", "load_metadata_csv_single_user", "(", "csv_in", ",", "header", ",", "tags_idx", ")", ":", "metadata", "=", "{", "}", "n_headers", "=", "len", "(", "header", ")", "for", "index", ",", "row", "in", "enumerate", "(", "csv_in", ",", "2", ")", ":", "...
Return the metadata as requested for a single user. :param csv_in: This field is the csv file to return metadata from. :param header: This field contains the headers in the csv file :param tags_idx: This field contains the index of the tags in the csv file.
[ "Return", "the", "metadata", "as", "requested", "for", "a", "single", "user", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L107-L136
OpenHumans/open-humans-api
ohapi/utils_fs.py
load_metadata_csv
def load_metadata_csv(input_filepath): """ Return dict of metadata. Format is either dict (filenames are keys) or dict-of-dicts (project member IDs as top level keys, then filenames as keys). :param input_filepath: This field is the filepath of the csv file. """ with open(input_filepath) a...
python
def load_metadata_csv(input_filepath): """ Return dict of metadata. Format is either dict (filenames are keys) or dict-of-dicts (project member IDs as top level keys, then filenames as keys). :param input_filepath: This field is the filepath of the csv file. """ with open(input_filepath) a...
[ "def", "load_metadata_csv", "(", "input_filepath", ")", ":", "with", "open", "(", "input_filepath", ")", "as", "f", ":", "csv_in", "=", "csv", ".", "reader", "(", "f", ")", "header", "=", "next", "(", "csv_in", ")", "if", "'tags'", "in", "header", ":",...
Return dict of metadata. Format is either dict (filenames are keys) or dict-of-dicts (project member IDs as top level keys, then filenames as keys). :param input_filepath: This field is the filepath of the csv file.
[ "Return", "dict", "of", "metadata", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L176-L206
OpenHumans/open-humans-api
ohapi/utils_fs.py
validate_date
def validate_date(date, project_member_id, filename): """ Check if date is in ISO 8601 format. :param date: This field is the date to be checked. :param project_member_id: This field is the project_member_id corresponding to the date provided. :param filename: This field is the filename cor...
python
def validate_date(date, project_member_id, filename): """ Check if date is in ISO 8601 format. :param date: This field is the date to be checked. :param project_member_id: This field is the project_member_id corresponding to the date provided. :param filename: This field is the filename cor...
[ "def", "validate_date", "(", "date", ",", "project_member_id", ",", "filename", ")", ":", "try", ":", "arrow", ".", "get", "(", "date", ")", "except", "Exception", ":", "return", "False", "return", "True" ]
Check if date is in ISO 8601 format. :param date: This field is the date to be checked. :param project_member_id: This field is the project_member_id corresponding to the date provided. :param filename: This field is the filename corresponding to the date provided.
[ "Check", "if", "date", "is", "in", "ISO", "8601", "format", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L218-L232
OpenHumans/open-humans-api
ohapi/utils_fs.py
is_single_file_metadata_valid
def is_single_file_metadata_valid(file_metadata, project_member_id, filename): """ Check if metadata fields like project member id, description, tags, md5 and creation date are valid for a single file. :param file_metadata: This field is metadata of file. :param project_member_id: This field is the...
python
def is_single_file_metadata_valid(file_metadata, project_member_id, filename): """ Check if metadata fields like project member id, description, tags, md5 and creation date are valid for a single file. :param file_metadata: This field is metadata of file. :param project_member_id: This field is the...
[ "def", "is_single_file_metadata_valid", "(", "file_metadata", ",", "project_member_id", ",", "filename", ")", ":", "if", "project_member_id", "is", "not", "None", ":", "if", "not", "project_member_id", ".", "isdigit", "(", ")", "or", "len", "(", "project_member_id...
Check if metadata fields like project member id, description, tags, md5 and creation date are valid for a single file. :param file_metadata: This field is metadata of file. :param project_member_id: This field is the project member id corresponding to the file metadata provided. :param filename...
[ "Check", "if", "metadata", "fields", "like", "project", "member", "id", "description", "tags", "md5", "and", "creation", "date", "are", "valid", "for", "a", "single", "file", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L235-L292
OpenHumans/open-humans-api
ohapi/utils_fs.py
review_metadata_csv_single_user
def review_metadata_csv_single_user(filedir, metadata, csv_in, n_headers): """ Check validity of metadata for single user. :param filedir: This field is the filepath of the directory whose csv has to be made. :param metadata: This field is the metadata generated from the load_metadata_c...
python
def review_metadata_csv_single_user(filedir, metadata, csv_in, n_headers): """ Check validity of metadata for single user. :param filedir: This field is the filepath of the directory whose csv has to be made. :param metadata: This field is the metadata generated from the load_metadata_c...
[ "def", "review_metadata_csv_single_user", "(", "filedir", ",", "metadata", ",", "csv_in", ",", "n_headers", ")", ":", "try", ":", "if", "not", "validate_metadata", "(", "filedir", ",", "metadata", ")", ":", "return", "False", "for", "filename", ",", "file_meta...
Check validity of metadata for single user. :param filedir: This field is the filepath of the directory whose csv has to be made. :param metadata: This field is the metadata generated from the load_metadata_csv function. :param csv_in: This field returns a reader object which iterates over ...
[ "Check", "validity", "of", "metadata", "for", "single", "user", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L295-L315
OpenHumans/open-humans-api
ohapi/utils_fs.py
validate_subfolders
def validate_subfolders(filedir, metadata): """ Check that all folders in the given directory have a corresponding entry in the metadata file, and vice versa. :param filedir: This field is the target directory from which to match metadata :param metadata: This field contains the metadata to...
python
def validate_subfolders(filedir, metadata): """ Check that all folders in the given directory have a corresponding entry in the metadata file, and vice versa. :param filedir: This field is the target directory from which to match metadata :param metadata: This field contains the metadata to...
[ "def", "validate_subfolders", "(", "filedir", ",", "metadata", ")", ":", "if", "not", "os", ".", "path", ".", "isdir", "(", "filedir", ")", ":", "print", "(", "\"Error: \"", "+", "filedir", "+", "\" is not a directory\"", ")", "return", "False", "subfolders"...
Check that all folders in the given directory have a corresponding entry in the metadata file, and vice versa. :param filedir: This field is the target directory from which to match metadata :param metadata: This field contains the metadata to be matched.
[ "Check", "that", "all", "folders", "in", "the", "given", "directory", "have", "a", "corresponding", "entry", "in", "the", "metadata", "file", "and", "vice", "versa", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L318-L341
OpenHumans/open-humans-api
ohapi/utils_fs.py
review_metadata_csv_multi_user
def review_metadata_csv_multi_user(filedir, metadata, csv_in, n_headers): """ Check validity of metadata for multi user. :param filedir: This field is the filepath of the directory whose csv has to be made. :param metadata: This field is the metadata generated from the load_metadata_csv...
python
def review_metadata_csv_multi_user(filedir, metadata, csv_in, n_headers): """ Check validity of metadata for multi user. :param filedir: This field is the filepath of the directory whose csv has to be made. :param metadata: This field is the metadata generated from the load_metadata_csv...
[ "def", "review_metadata_csv_multi_user", "(", "filedir", ",", "metadata", ",", "csv_in", ",", "n_headers", ")", ":", "try", ":", "if", "not", "validate_subfolders", "(", "filedir", ",", "metadata", ")", ":", "return", "False", "for", "project_member_id", ",", ...
Check validity of metadata for multi user. :param filedir: This field is the filepath of the directory whose csv has to be made. :param metadata: This field is the metadata generated from the load_metadata_csv function. :param csv_in: This field returns a reader object which iterates over t...
[ "Check", "validity", "of", "metadata", "for", "multi", "user", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L344-L371
OpenHumans/open-humans-api
ohapi/utils_fs.py
review_metadata_csv
def review_metadata_csv(filedir, input_filepath): """ Check validity of metadata fields. :param filedir: This field is the filepath of the directory whose csv has to be made. :param outputfilepath: This field is the file path of the output csv. :param max_bytes: This field is the maximum fi...
python
def review_metadata_csv(filedir, input_filepath): """ Check validity of metadata fields. :param filedir: This field is the filepath of the directory whose csv has to be made. :param outputfilepath: This field is the file path of the output csv. :param max_bytes: This field is the maximum fi...
[ "def", "review_metadata_csv", "(", "filedir", ",", "input_filepath", ")", ":", "try", ":", "metadata", "=", "load_metadata_csv", "(", "input_filepath", ")", "except", "ValueError", "as", "e", ":", "print_error", "(", "e", ")", "return", "False", "with", "open"...
Check validity of metadata fields. :param filedir: This field is the filepath of the directory whose csv has to be made. :param outputfilepath: This field is the file path of the output csv. :param max_bytes: This field is the maximum file size to consider. Its default value is 128m.
[ "Check", "validity", "of", "metadata", "fields", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L374-L401
OpenHumans/open-humans-api
ohapi/utils_fs.py
write_metadata_to_filestream
def write_metadata_to_filestream(filedir, filestream, max_bytes=MAX_FILE_DEFAULT): """ Make metadata file for all files in a directory(helper function) :param filedir: This field is the filepath of the directory whose csv has to be made. :param filestream: This ...
python
def write_metadata_to_filestream(filedir, filestream, max_bytes=MAX_FILE_DEFAULT): """ Make metadata file for all files in a directory(helper function) :param filedir: This field is the filepath of the directory whose csv has to be made. :param filestream: This ...
[ "def", "write_metadata_to_filestream", "(", "filedir", ",", "filestream", ",", "max_bytes", "=", "MAX_FILE_DEFAULT", ")", ":", "csv_out", "=", "csv", ".", "writer", "(", "filestream", ")", "subdirs", "=", "[", "os", ".", "path", ".", "join", "(", "filedir", ...
Make metadata file for all files in a directory(helper function) :param filedir: This field is the filepath of the directory whose csv has to be made. :param filestream: This field is a stream for writing to the csv. :param max_bytes: This field is the maximum file size to consider. Its def...
[ "Make", "metadata", "file", "for", "all", "files", "in", "a", "directory", "(", "helper", "function", ")" ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L404-L452
OpenHumans/open-humans-api
ohapi/utils_fs.py
mk_metadata_csv
def mk_metadata_csv(filedir, outputfilepath, max_bytes=MAX_FILE_DEFAULT): """ Make metadata file for all files in a directory. :param filedir: This field is the filepath of the directory whose csv has to be made. :param outputfilepath: This field is the file path of the output csv. :param m...
python
def mk_metadata_csv(filedir, outputfilepath, max_bytes=MAX_FILE_DEFAULT): """ Make metadata file for all files in a directory. :param filedir: This field is the filepath of the directory whose csv has to be made. :param outputfilepath: This field is the file path of the output csv. :param m...
[ "def", "mk_metadata_csv", "(", "filedir", ",", "outputfilepath", ",", "max_bytes", "=", "MAX_FILE_DEFAULT", ")", ":", "with", "open", "(", "outputfilepath", ",", "'w'", ")", "as", "filestream", ":", "write_metadata_to_filestream", "(", "filedir", ",", "filestream"...
Make metadata file for all files in a directory. :param filedir: This field is the filepath of the directory whose csv has to be made. :param outputfilepath: This field is the file path of the output csv. :param max_bytes: This field is the maximum file size to consider. Its default value i...
[ "Make", "metadata", "file", "for", "all", "files", "in", "a", "directory", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L455-L466
OpenHumans/open-humans-api
ohapi/utils_fs.py
download_file
def download_file(download_url, target_filepath, max_bytes=MAX_FILE_DEFAULT): """ Download a file. :param download_url: This field is the url from which data will be downloaded. :param target_filepath: This field is the path of the file where data will be downloaded. :param max_byte...
python
def download_file(download_url, target_filepath, max_bytes=MAX_FILE_DEFAULT): """ Download a file. :param download_url: This field is the url from which data will be downloaded. :param target_filepath: This field is the path of the file where data will be downloaded. :param max_byte...
[ "def", "download_file", "(", "download_url", ",", "target_filepath", ",", "max_bytes", "=", "MAX_FILE_DEFAULT", ")", ":", "response", "=", "requests", ".", "get", "(", "download_url", ",", "stream", "=", "True", ")", "size", "=", "int", "(", "response", ".",...
Download a file. :param download_url: This field is the url from which data will be downloaded. :param target_filepath: This field is the path of the file where data will be downloaded. :param max_bytes: This field is the maximum file size to download. Its default value is 128m.
[ "Download", "a", "file", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L469-L506
OpenHumans/open-humans-api
ohapi/utils_fs.py
read_id_list
def read_id_list(filepath): """ Get project member id from a file. :param filepath: This field is the path of file to read. """ if not filepath: return None id_list = [] with open(filepath) as f: for line in f: line = line.rstrip() if not re.match('^[...
python
def read_id_list(filepath): """ Get project member id from a file. :param filepath: This field is the path of file to read. """ if not filepath: return None id_list = [] with open(filepath) as f: for line in f: line = line.rstrip() if not re.match('^[...
[ "def", "read_id_list", "(", "filepath", ")", ":", "if", "not", "filepath", ":", "return", "None", "id_list", "=", "[", "]", "with", "open", "(", "filepath", ")", "as", "f", ":", "for", "line", "in", "f", ":", "line", "=", "line", ".", "rstrip", "("...
Get project member id from a file. :param filepath: This field is the path of file to read.
[ "Get", "project", "member", "id", "from", "a", "file", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/utils_fs.py#L509-L526
OpenHumans/open-humans-api
ohapi/command_line.py
set_log_level
def set_log_level(debug, verbose): """ Function for setting the logging level. :param debug: This boolean field is the logging level. :param verbose: This boolean field is the logging level. """ if debug: logging.basicConfig(level=logging.DEBUG) elif verbose: logging.basicCo...
python
def set_log_level(debug, verbose): """ Function for setting the logging level. :param debug: This boolean field is the logging level. :param verbose: This boolean field is the logging level. """ if debug: logging.basicConfig(level=logging.DEBUG) elif verbose: logging.basicCo...
[ "def", "set_log_level", "(", "debug", ",", "verbose", ")", ":", "if", "debug", ":", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", "DEBUG", ")", "elif", "verbose", ":", "logging", ".", "basicConfig", "(", "level", "=", "logging", ".", ...
Function for setting the logging level. :param debug: This boolean field is the logging level. :param verbose: This boolean field is the logging level.
[ "Function", "for", "setting", "the", "logging", "level", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L24-L34
OpenHumans/open-humans-api
ohapi/command_line.py
download_cli
def download_cli(directory, master_token=None, member=None, access_token=None, source=None, project_data=False, max_size='128m', verbose=False, debug=False, memberlist=None, excludelist=None, id_filename=False): """ Command line function for downloading data fr...
python
def download_cli(directory, master_token=None, member=None, access_token=None, source=None, project_data=False, max_size='128m', verbose=False, debug=False, memberlist=None, excludelist=None, id_filename=False): """ Command line function for downloading data fr...
[ "def", "download_cli", "(", "directory", ",", "master_token", "=", "None", ",", "member", "=", "None", ",", "access_token", "=", "None", ",", "source", "=", "None", ",", "project_data", "=", "False", ",", "max_size", "=", "'128m'", ",", "verbose", "=", "...
Command line function for downloading data from project members to the target directory. For more information visit :func:`download<ohapi.command_line.download>`.
[ "Command", "line", "function", "for", "downloading", "data", "from", "project", "members", "to", "the", "target", "directory", ".", "For", "more", "information", "visit", ":", "func", ":", "download<ohapi", ".", "command_line", ".", "download", ">", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L56-L67
OpenHumans/open-humans-api
ohapi/command_line.py
download
def download(directory, master_token=None, member=None, access_token=None, source=None, project_data=False, max_size='128m', verbose=False, debug=False, memberlist=None, excludelist=None, id_filename=False): """ Download data from project members to the target directory. ...
python
def download(directory, master_token=None, member=None, access_token=None, source=None, project_data=False, max_size='128m', verbose=False, debug=False, memberlist=None, excludelist=None, id_filename=False): """ Download data from project members to the target directory. ...
[ "def", "download", "(", "directory", ",", "master_token", "=", "None", ",", "member", "=", "None", ",", "access_token", "=", "None", ",", "source", "=", "None", ",", "project_data", "=", "False", ",", "max_size", "=", "'128m'", ",", "verbose", "=", "Fals...
Download data from project members to the target directory. Unless this is a member-specific download, directories will be created for each project member ID. Also, unless a source is specified, all shared sources are downloaded and data is sorted into subdirectories according to source. Projects ...
[ "Download", "data", "from", "project", "members", "to", "the", "target", "directory", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L70-L158
OpenHumans/open-humans-api
ohapi/command_line.py
download_metadata_cli
def download_metadata_cli(master_token, output_csv, verbose=False, debug=False): """ Command line function for downloading metadata. For more information visit :func:`download_metadata<ohapi.command_line.download_metadata>`. """ return download_metadata(master_token, ou...
python
def download_metadata_cli(master_token, output_csv, verbose=False, debug=False): """ Command line function for downloading metadata. For more information visit :func:`download_metadata<ohapi.command_line.download_metadata>`. """ return download_metadata(master_token, ou...
[ "def", "download_metadata_cli", "(", "master_token", ",", "output_csv", ",", "verbose", "=", "False", ",", "debug", "=", "False", ")", ":", "return", "download_metadata", "(", "master_token", ",", "output_csv", ",", "verbose", ",", "debug", ")" ]
Command line function for downloading metadata. For more information visit :func:`download_metadata<ohapi.command_line.download_metadata>`.
[ "Command", "line", "function", "for", "downloading", "metadata", ".", "For", "more", "information", "visit", ":", "func", ":", "download_metadata<ohapi", ".", "command_line", ".", "download_metadata", ">", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L168-L175
OpenHumans/open-humans-api
ohapi/command_line.py
download_metadata
def download_metadata(master_token, output_csv, verbose=False, debug=False): """ Output CSV with metadata for a project's downloadable files in Open Humans. :param master_token: This field is the master access token for the project. :param output_csv: This field is the target csv file to which metadata...
python
def download_metadata(master_token, output_csv, verbose=False, debug=False): """ Output CSV with metadata for a project's downloadable files in Open Humans. :param master_token: This field is the master access token for the project. :param output_csv: This field is the target csv file to which metadata...
[ "def", "download_metadata", "(", "master_token", ",", "output_csv", ",", "verbose", "=", "False", ",", "debug", "=", "False", ")", ":", "set_log_level", "(", "debug", ",", "verbose", ")", "project", "=", "OHProject", "(", "master_access_token", "=", "master_to...
Output CSV with metadata for a project's downloadable files in Open Humans. :param master_token: This field is the master access token for the project. :param output_csv: This field is the target csv file to which metadata is written. :param verbose: This boolean field is the logging level. It's de...
[ "Output", "CSV", "with", "metadata", "for", "a", "project", "s", "downloadable", "files", "in", "Open", "Humans", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L178-L208
OpenHumans/open-humans-api
ohapi/command_line.py
upload_metadata_cli
def upload_metadata_cli(directory, create_csv='', review='', max_size='128m', verbose=False, debug=False): """ Command line function for drafting or reviewing metadata files. For more information visit :func:`upload_metadata<ohapi.command_line.upload_metadata>`. """ retur...
python
def upload_metadata_cli(directory, create_csv='', review='', max_size='128m', verbose=False, debug=False): """ Command line function for drafting or reviewing metadata files. For more information visit :func:`upload_metadata<ohapi.command_line.upload_metadata>`. """ retur...
[ "def", "upload_metadata_cli", "(", "directory", ",", "create_csv", "=", "''", ",", "review", "=", "''", ",", "max_size", "=", "'128m'", ",", "verbose", "=", "False", ",", "debug", "=", "False", ")", ":", "return", "upload_metadata", "(", "directory", ",", ...
Command line function for drafting or reviewing metadata files. For more information visit :func:`upload_metadata<ohapi.command_line.upload_metadata>`.
[ "Command", "line", "function", "for", "drafting", "or", "reviewing", "metadata", "files", ".", "For", "more", "information", "visit", ":", "func", ":", "upload_metadata<ohapi", ".", "command_line", ".", "upload_metadata", ">", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L219-L227
OpenHumans/open-humans-api
ohapi/command_line.py
upload_metadata
def upload_metadata(directory, create_csv='', review='', max_size='128m', verbose=False, debug=False): """ Draft or review metadata files for uploading files to Open Humans. The target directory should either represent files for a single member (no subdirectories), or contain a subdi...
python
def upload_metadata(directory, create_csv='', review='', max_size='128m', verbose=False, debug=False): """ Draft or review metadata files for uploading files to Open Humans. The target directory should either represent files for a single member (no subdirectories), or contain a subdi...
[ "def", "upload_metadata", "(", "directory", ",", "create_csv", "=", "''", ",", "review", "=", "''", ",", "max_size", "=", "'128m'", ",", "verbose", "=", "False", ",", "debug", "=", "False", ")", ":", "set_log_level", "(", "debug", ",", "verbose", ")", ...
Draft or review metadata files for uploading files to Open Humans. The target directory should either represent files for a single member (no subdirectories), or contain a subdirectory for each project member ID. :param directory: This field is the directory for which metadata has to be created. ...
[ "Draft", "or", "review", "metadata", "files", "for", "uploading", "files", "to", "Open", "Humans", ".", "The", "target", "directory", "should", "either", "represent", "files", "for", "a", "single", "member", "(", "no", "subdirectories", ")", "or", "contain", ...
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L230-L261
OpenHumans/open-humans-api
ohapi/command_line.py
upload_cli
def upload_cli(directory, metadata_csv, master_token=None, member=None, access_token=None, safe=False, sync=False, max_size='128m', mode='default', verbose=False, debug=False): """ Command line function for uploading files to OH. For more information visit :func:`upload<oha...
python
def upload_cli(directory, metadata_csv, master_token=None, member=None, access_token=None, safe=False, sync=False, max_size='128m', mode='default', verbose=False, debug=False): """ Command line function for uploading files to OH. For more information visit :func:`upload<oha...
[ "def", "upload_cli", "(", "directory", ",", "metadata_csv", ",", "master_token", "=", "None", ",", "member", "=", "None", ",", "access_token", "=", "None", ",", "safe", "=", "False", ",", "sync", "=", "False", ",", "max_size", "=", "'128m'", ",", "mode",...
Command line function for uploading files to OH. For more information visit :func:`upload<ohapi.command_line.upload>`.
[ "Command", "line", "function", "for", "uploading", "files", "to", "OH", ".", "For", "more", "information", "visit", ":", "func", ":", "upload<ohapi", ".", "command_line", ".", "upload", ">", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L282-L292
OpenHumans/open-humans-api
ohapi/command_line.py
upload
def upload(directory, metadata_csv, master_token=None, member=None, access_token=None, safe=False, sync=False, max_size='128m', mode='default', verbose=False, debug=False): """ Upload files for the project to Open Humans member accounts. If using a master access token and not specifyi...
python
def upload(directory, metadata_csv, master_token=None, member=None, access_token=None, safe=False, sync=False, max_size='128m', mode='default', verbose=False, debug=False): """ Upload files for the project to Open Humans member accounts. If using a master access token and not specifyi...
[ "def", "upload", "(", "directory", ",", "metadata_csv", ",", "master_token", "=", "None", ",", "member", "=", "None", ",", "access_token", "=", "None", ",", "safe", "=", "False", ",", "sync", "=", "False", ",", "max_size", "=", "'128m'", ",", "mode", "...
Upload files for the project to Open Humans member accounts. If using a master access token and not specifying member ID: (1) Files should be organized in subdirectories according to project member ID, e.g.: main_directory/01234567/data.json main_directory/12345678/data.json main_...
[ "Upload", "files", "for", "the", "project", "to", "Open", "Humans", "member", "accounts", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L295-L411
OpenHumans/open-humans-api
ohapi/command_line.py
oauth_token_exchange_cli
def oauth_token_exchange_cli(client_id, client_secret, redirect_uri, base_url=OH_BASE_URL, code=None, refresh_token=None): """ Command line function for obtaining the refresh token/code. For more information visit :func:`oauth2_token_exchange<oha...
python
def oauth_token_exchange_cli(client_id, client_secret, redirect_uri, base_url=OH_BASE_URL, code=None, refresh_token=None): """ Command line function for obtaining the refresh token/code. For more information visit :func:`oauth2_token_exchange<oha...
[ "def", "oauth_token_exchange_cli", "(", "client_id", ",", "client_secret", ",", "redirect_uri", ",", "base_url", "=", "OH_BASE_URL", ",", "code", "=", "None", ",", "refresh_token", "=", "None", ")", ":", "print", "(", "oauth2_token_exchange", "(", "client_id", "...
Command line function for obtaining the refresh token/code. For more information visit :func:`oauth2_token_exchange<ohapi.api.oauth2_token_exchange>`.
[ "Command", "line", "function", "for", "obtaining", "the", "refresh", "token", "/", "code", ".", "For", "more", "information", "visit", ":", "func", ":", "oauth2_token_exchange<ohapi", ".", "api", ".", "oauth2_token_exchange", ">", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L427-L436
OpenHumans/open-humans-api
ohapi/command_line.py
oauth2_auth_url_cli
def oauth2_auth_url_cli(redirect_uri=None, client_id=None, base_url=OH_BASE_URL): """ Command line function for obtaining the Oauth2 url. For more information visit :func:`oauth2_auth_url<ohapi.api.oauth2_auth_url>`. """ result = oauth2_auth_url(redirect_uri, client_id, b...
python
def oauth2_auth_url_cli(redirect_uri=None, client_id=None, base_url=OH_BASE_URL): """ Command line function for obtaining the Oauth2 url. For more information visit :func:`oauth2_auth_url<ohapi.api.oauth2_auth_url>`. """ result = oauth2_auth_url(redirect_uri, client_id, b...
[ "def", "oauth2_auth_url_cli", "(", "redirect_uri", "=", "None", ",", "client_id", "=", "None", ",", "base_url", "=", "OH_BASE_URL", ")", ":", "result", "=", "oauth2_auth_url", "(", "redirect_uri", ",", "client_id", ",", "base_url", ")", "print", "(", "'The req...
Command line function for obtaining the Oauth2 url. For more information visit :func:`oauth2_auth_url<ohapi.api.oauth2_auth_url>`.
[ "Command", "line", "function", "for", "obtaining", "the", "Oauth2", "url", ".", "For", "more", "information", "visit", ":", "func", ":", "oauth2_auth_url<ohapi", ".", "api", ".", "oauth2_auth_url", ">", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L444-L453
OpenHumans/open-humans-api
ohapi/command_line.py
message_cli
def message_cli(subject, message_body, access_token, all_members=False, project_member_ids=None, base_url=OH_BASE_URL, verbose=False, debug=False): """ Command line function for sending email to a single user or in bulk. For more information visit :func:`message<ohapi.api...
python
def message_cli(subject, message_body, access_token, all_members=False, project_member_ids=None, base_url=OH_BASE_URL, verbose=False, debug=False): """ Command line function for sending email to a single user or in bulk. For more information visit :func:`message<ohapi.api...
[ "def", "message_cli", "(", "subject", ",", "message_body", ",", "access_token", ",", "all_members", "=", "False", ",", "project_member_ids", "=", "None", ",", "base_url", "=", "OH_BASE_URL", ",", "verbose", "=", "False", ",", "debug", "=", "False", ")", ":",...
Command line function for sending email to a single user or in bulk. For more information visit :func:`message<ohapi.api.message>`.
[ "Command", "line", "function", "for", "sending", "email", "to", "a", "single", "user", "or", "in", "bulk", ".", "For", "more", "information", "visit", ":", "func", ":", "message<ohapi", ".", "api", ".", "message", ">", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L468-L480
OpenHumans/open-humans-api
ohapi/command_line.py
delete_cli
def delete_cli(access_token, project_member_id, base_url=OH_BASE_URL, file_basename=None, file_id=None, all_files=False): """ Command line function for deleting files. For more information visit :func:`delete_file<ohapi.api.delete_file>`. """ response = delete_file(access_token, p...
python
def delete_cli(access_token, project_member_id, base_url=OH_BASE_URL, file_basename=None, file_id=None, all_files=False): """ Command line function for deleting files. For more information visit :func:`delete_file<ohapi.api.delete_file>`. """ response = delete_file(access_token, p...
[ "def", "delete_cli", "(", "access_token", ",", "project_member_id", ",", "base_url", "=", "OH_BASE_URL", ",", "file_basename", "=", "None", ",", "file_id", "=", "None", ",", "all_files", "=", "False", ")", ":", "response", "=", "delete_file", "(", "access_toke...
Command line function for deleting files. For more information visit :func:`delete_file<ohapi.api.delete_file>`.
[ "Command", "line", "function", "for", "deleting", "files", ".", "For", "more", "information", "visit", ":", "func", ":", "delete_file<ohapi", ".", "api", ".", "delete_file", ">", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L491-L503
OpenHumans/open-humans-api
ohapi/command_line.py
public_data_download_cli
def public_data_download_cli(source, username, directory, max_size, quiet, debug): """ Command line tools for downloading public data. """ return public_download(source, username, directory, max_size, quiet, debug)
python
def public_data_download_cli(source, username, directory, max_size, quiet, debug): """ Command line tools for downloading public data. """ return public_download(source, username, directory, max_size, quiet, debug)
[ "def", "public_data_download_cli", "(", "source", ",", "username", ",", "directory", ",", "max_size", ",", "quiet", ",", "debug", ")", ":", "return", "public_download", "(", "source", ",", "username", ",", "directory", ",", "max_size", ",", "quiet", ",", "de...
Command line tools for downloading public data.
[ "Command", "line", "tools", "for", "downloading", "public", "data", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/command_line.py#L517-L522
OpenHumans/open-humans-api
ohapi/public.py
download_url
def download_url(result, directory, max_bytes): """ Download a file. :param result: This field contains a url from which data will be downloaded. :param directory: This field is the target directory to which data will be downloaded. :param max_bytes: This field is the maximum file s...
python
def download_url(result, directory, max_bytes): """ Download a file. :param result: This field contains a url from which data will be downloaded. :param directory: This field is the target directory to which data will be downloaded. :param max_bytes: This field is the maximum file s...
[ "def", "download_url", "(", "result", ",", "directory", ",", "max_bytes", ")", ":", "response", "=", "requests", ".", "get", "(", "result", "[", "'download_url'", "]", ",", "stream", "=", "True", ")", "# TODO: make this more robust by parsing the URL", "filename",...
Download a file. :param result: This field contains a url from which data will be downloaded. :param directory: This field is the target directory to which data will be downloaded. :param max_bytes: This field is the maximum file size in bytes.
[ "Download", "a", "file", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/public.py#L37-L99
OpenHumans/open-humans-api
ohapi/public.py
download
def download(source=None, username=None, directory='.', max_size='128m', quiet=None, debug=None): """ Download public data from Open Humans. :param source: This field is the data source from which to download. It's default value is None. :param username: This fiels is username of u...
python
def download(source=None, username=None, directory='.', max_size='128m', quiet=None, debug=None): """ Download public data from Open Humans. :param source: This field is the data source from which to download. It's default value is None. :param username: This fiels is username of u...
[ "def", "download", "(", "source", "=", "None", ",", "username", "=", "None", ",", "directory", "=", "'.'", ",", "max_size", "=", "'128m'", ",", "quiet", "=", "None", ",", "debug", "=", "None", ")", ":", "if", "debug", ":", "logging", ".", "basicConfi...
Download public data from Open Humans. :param source: This field is the data source from which to download. It's default value is None. :param username: This fiels is username of user. It's default value is None. :param directory: This field is the target directory to which data is ...
[ "Download", "public", "data", "from", "Open", "Humans", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/public.py#L102-L172
OpenHumans/open-humans-api
ohapi/public.py
get_members_by_source
def get_members_by_source(base_url=BASE_URL_API): """ Function returns which members have joined each activity. :param base_url: It is URL: `https://www.openhumans.org/api/public-data`. """ url = '{}members-by-source/'.format(base_url) response = get_page(url) return response
python
def get_members_by_source(base_url=BASE_URL_API): """ Function returns which members have joined each activity. :param base_url: It is URL: `https://www.openhumans.org/api/public-data`. """ url = '{}members-by-source/'.format(base_url) response = get_page(url) return response
[ "def", "get_members_by_source", "(", "base_url", "=", "BASE_URL_API", ")", ":", "url", "=", "'{}members-by-source/'", ".", "format", "(", "base_url", ")", "response", "=", "get_page", "(", "url", ")", "return", "response" ]
Function returns which members have joined each activity. :param base_url: It is URL: `https://www.openhumans.org/api/public-data`.
[ "Function", "returns", "which", "members", "have", "joined", "each", "activity", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/public.py#L175-L183
OpenHumans/open-humans-api
ohapi/public.py
get_sources_by_member
def get_sources_by_member(base_url=BASE_URL_API, limit=LIMIT_DEFAULT): """ Function returns which activities each member has joined. :param base_url: It is URL: `https://www.openhumans.org/api/public-data`. :param limit: It is the limit of data send by one request. """ url = '{}sources-by-membe...
python
def get_sources_by_member(base_url=BASE_URL_API, limit=LIMIT_DEFAULT): """ Function returns which activities each member has joined. :param base_url: It is URL: `https://www.openhumans.org/api/public-data`. :param limit: It is the limit of data send by one request. """ url = '{}sources-by-membe...
[ "def", "get_sources_by_member", "(", "base_url", "=", "BASE_URL_API", ",", "limit", "=", "LIMIT_DEFAULT", ")", ":", "url", "=", "'{}sources-by-member/'", ".", "format", "(", "base_url", ")", "page", "=", "'{}?{}'", ".", "format", "(", "url", ",", "urlencode", ...
Function returns which activities each member has joined. :param base_url: It is URL: `https://www.openhumans.org/api/public-data`. :param limit: It is the limit of data send by one request.
[ "Function", "returns", "which", "activities", "each", "member", "has", "joined", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/public.py#L186-L203
OpenHumans/open-humans-api
ohapi/projects.py
OHProject._get_member_file_data
def _get_member_file_data(member_data, id_filename=False): """ Helper function to get file data of member of a project. :param member_data: This field is data related to member in a project. """ file_data = {} for datafile in member_data['data']: if id_filena...
python
def _get_member_file_data(member_data, id_filename=False): """ Helper function to get file data of member of a project. :param member_data: This field is data related to member in a project. """ file_data = {} for datafile in member_data['data']: if id_filena...
[ "def", "_get_member_file_data", "(", "member_data", ",", "id_filename", "=", "False", ")", ":", "file_data", "=", "{", "}", "for", "datafile", "in", "member_data", "[", "'data'", "]", ":", "if", "id_filename", ":", "basename", "=", "'{}.{}'", ".", "format", ...
Helper function to get file data of member of a project. :param member_data: This field is data related to member in a project.
[ "Helper", "function", "to", "get", "file", "data", "of", "member", "of", "a", "project", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/projects.py#L27-L43
OpenHumans/open-humans-api
ohapi/projects.py
OHProject.update_data
def update_data(self): """ Returns data for all users including shared data files. """ url = ('https://www.openhumans.org/api/direct-sharing/project/' 'members/?access_token={}'.format(self.master_access_token)) results = get_all_results(url) self.project_d...
python
def update_data(self): """ Returns data for all users including shared data files. """ url = ('https://www.openhumans.org/api/direct-sharing/project/' 'members/?access_token={}'.format(self.master_access_token)) results = get_all_results(url) self.project_d...
[ "def", "update_data", "(", "self", ")", ":", "url", "=", "(", "'https://www.openhumans.org/api/direct-sharing/project/'", "'members/?access_token={}'", ".", "format", "(", "self", ".", "master_access_token", ")", ")", "results", "=", "get_all_results", "(", "url", ")"...
Returns data for all users including shared data files.
[ "Returns", "data", "for", "all", "users", "including", "shared", "data", "files", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/projects.py#L45-L63
OpenHumans/open-humans-api
ohapi/projects.py
OHProject.download_member_project_data
def download_member_project_data(cls, member_data, target_member_dir, max_size=MAX_SIZE_DEFAULT, id_filename=False): """ Download files to sync a local dir to match OH member project data. :param member_data: This field i...
python
def download_member_project_data(cls, member_data, target_member_dir, max_size=MAX_SIZE_DEFAULT, id_filename=False): """ Download files to sync a local dir to match OH member project data. :param member_data: This field i...
[ "def", "download_member_project_data", "(", "cls", ",", "member_data", ",", "target_member_dir", ",", "max_size", "=", "MAX_SIZE_DEFAULT", ",", "id_filename", "=", "False", ")", ":", "logging", ".", "debug", "(", "'Download member project data...'", ")", "sources_shar...
Download files to sync a local dir to match OH member project data. :param member_data: This field is data related to member in a project. :param target_member_dir: This field is the target directory where data will be downloaded. :param max_size: This field is the maximum file size...
[ "Download", "files", "to", "sync", "a", "local", "dir", "to", "match", "OH", "member", "project", "data", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/projects.py#L66-L91
OpenHumans/open-humans-api
ohapi/projects.py
OHProject.download_member_shared
def download_member_shared(cls, member_data, target_member_dir, source=None, max_size=MAX_SIZE_DEFAULT, id_filename=False): """ Download files to sync a local dir to match OH member shared data. Files are downloaded to match their "basename" on Open Humans. ...
python
def download_member_shared(cls, member_data, target_member_dir, source=None, max_size=MAX_SIZE_DEFAULT, id_filename=False): """ Download files to sync a local dir to match OH member shared data. Files are downloaded to match their "basename" on Open Humans. ...
[ "def", "download_member_shared", "(", "cls", ",", "member_data", ",", "target_member_dir", ",", "source", "=", "None", ",", "max_size", "=", "MAX_SIZE_DEFAULT", ",", "id_filename", "=", "False", ")", ":", "logging", ".", "debug", "(", "'Download member shared data...
Download files to sync a local dir to match OH member shared data. Files are downloaded to match their "basename" on Open Humans. If there are multiple files with the same name, the most recent is downloaded. :param member_data: This field is data related to member in a project. ...
[ "Download", "files", "to", "sync", "a", "local", "dir", "to", "match", "OH", "member", "shared", "data", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/projects.py#L94-L137
OpenHumans/open-humans-api
ohapi/projects.py
OHProject.download_all
def download_all(self, target_dir, source=None, project_data=False, memberlist=None, excludelist=None, max_size=MAX_SIZE_DEFAULT, id_filename=False): """ Download data for all users including shared data files. :param target_dir: This field is the targe...
python
def download_all(self, target_dir, source=None, project_data=False, memberlist=None, excludelist=None, max_size=MAX_SIZE_DEFAULT, id_filename=False): """ Download data for all users including shared data files. :param target_dir: This field is the targe...
[ "def", "download_all", "(", "self", ",", "target_dir", ",", "source", "=", "None", ",", "project_data", "=", "False", ",", "memberlist", "=", "None", ",", "excludelist", "=", "None", ",", "max_size", "=", "MAX_SIZE_DEFAULT", ",", "id_filename", "=", "False",...
Download data for all users including shared data files. :param target_dir: This field is the target directory to download data. :param source: This field is the data source. It's default value is None. :param project_data: This field is data related to particular project. ...
[ "Download", "data", "for", "all", "users", "including", "shared", "data", "files", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/projects.py#L139-L180
OpenHumans/open-humans-api
ohapi/projects.py
OHProject.upload_member_from_dir
def upload_member_from_dir(member_data, target_member_dir, metadata, access_token, mode='default', max_size=MAX_SIZE_DEFAULT): """ Upload files in target directory to an Open Humans member's account. The default behavior is to overwr...
python
def upload_member_from_dir(member_data, target_member_dir, metadata, access_token, mode='default', max_size=MAX_SIZE_DEFAULT): """ Upload files in target directory to an Open Humans member's account. The default behavior is to overwr...
[ "def", "upload_member_from_dir", "(", "member_data", ",", "target_member_dir", ",", "metadata", ",", "access_token", ",", "mode", "=", "'default'", ",", "max_size", "=", "MAX_SIZE_DEFAULT", ")", ":", "if", "not", "validate_metadata", "(", "target_member_dir", ",", ...
Upload files in target directory to an Open Humans member's account. The default behavior is to overwrite files with matching filenames on Open Humans, but not otherwise delete files. If the 'mode' parameter is 'safe': matching filenames will not be overwritten. If the 'mode' ...
[ "Upload", "files", "in", "target", "directory", "to", "an", "Open", "Humans", "member", "s", "account", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/projects.py#L183-L232
OpenHumans/open-humans-api
ohapi/api.py
oauth2_auth_url
def oauth2_auth_url(redirect_uri=None, client_id=None, base_url=OH_BASE_URL): """ Returns an OAuth2 authorization URL for a project, given Client ID. This function constructs an authorization URL for a user to follow. The user will be redirected to Authorize Open Humans data for our external applica...
python
def oauth2_auth_url(redirect_uri=None, client_id=None, base_url=OH_BASE_URL): """ Returns an OAuth2 authorization URL for a project, given Client ID. This function constructs an authorization URL for a user to follow. The user will be redirected to Authorize Open Humans data for our external applica...
[ "def", "oauth2_auth_url", "(", "redirect_uri", "=", "None", ",", "client_id", "=", "None", ",", "base_url", "=", "OH_BASE_URL", ")", ":", "if", "not", "client_id", ":", "client_id", "=", "os", ".", "getenv", "(", "'OHAPI_CLIENT_ID'", ")", "if", "not", "cli...
Returns an OAuth2 authorization URL for a project, given Client ID. This function constructs an authorization URL for a user to follow. The user will be redirected to Authorize Open Humans data for our external application. An OAuth2 project on Open Humans is required for this to properly work. To learn...
[ "Returns", "an", "OAuth2", "authorization", "URL", "for", "a", "project", "given", "Client", "ID", ".", "This", "function", "constructs", "an", "authorization", "URL", "for", "a", "user", "to", "follow", ".", "The", "user", "will", "be", "redirected", "to", ...
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L27-L60
OpenHumans/open-humans-api
ohapi/api.py
oauth2_token_exchange
def oauth2_token_exchange(client_id, client_secret, redirect_uri, base_url=OH_BASE_URL, code=None, refresh_token=None): """ Exchange code or refresh token for a new token and refresh token. For the first time when a project is created, code is required to generate refresh token...
python
def oauth2_token_exchange(client_id, client_secret, redirect_uri, base_url=OH_BASE_URL, code=None, refresh_token=None): """ Exchange code or refresh token for a new token and refresh token. For the first time when a project is created, code is required to generate refresh token...
[ "def", "oauth2_token_exchange", "(", "client_id", ",", "client_secret", ",", "redirect_uri", ",", "base_url", "=", "OH_BASE_URL", ",", "code", "=", "None", ",", "refresh_token", "=", "None", ")", ":", "if", "not", "(", "code", "or", "refresh_token", ")", "or...
Exchange code or refresh token for a new token and refresh token. For the first time when a project is created, code is required to generate refresh token. Once the refresh token is obtained, it can be used later on for obtaining new access token and refresh token. The user must store the refresh token ...
[ "Exchange", "code", "or", "refresh", "token", "for", "a", "new", "token", "and", "refresh", "token", ".", "For", "the", "first", "time", "when", "a", "project", "is", "created", "code", "is", "required", "to", "generate", "refresh", "token", ".", "Once", ...
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L63-L101
OpenHumans/open-humans-api
ohapi/api.py
get_page
def get_page(url): """ Get a single page of results. :param url: This field is the url from which data will be requested. """ response = requests.get(url) handle_error(response, 200) data = response.json() return data
python
def get_page(url): """ Get a single page of results. :param url: This field is the url from which data will be requested. """ response = requests.get(url) handle_error(response, 200) data = response.json() return data
[ "def", "get_page", "(", "url", ")", ":", "response", "=", "requests", ".", "get", "(", "url", ")", "handle_error", "(", "response", ",", "200", ")", "data", "=", "response", ".", "json", "(", ")", "return", "data" ]
Get a single page of results. :param url: This field is the url from which data will be requested.
[ "Get", "a", "single", "page", "of", "results", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L104-L113
OpenHumans/open-humans-api
ohapi/api.py
get_all_results
def get_all_results(starting_page): """ Given starting API query for Open Humans, iterate to get all results. :param starting page: This field is the first page, starting from which results will be obtained. """ logging.info('Retrieving all results for {}'.format(starting_page)) page = ...
python
def get_all_results(starting_page): """ Given starting API query for Open Humans, iterate to get all results. :param starting page: This field is the first page, starting from which results will be obtained. """ logging.info('Retrieving all results for {}'.format(starting_page)) page = ...
[ "def", "get_all_results", "(", "starting_page", ")", ":", "logging", ".", "info", "(", "'Retrieving all results for {}'", ".", "format", "(", "starting_page", ")", ")", "page", "=", "starting_page", "results", "=", "[", "]", "while", "True", ":", "logging", "....
Given starting API query for Open Humans, iterate to get all results. :param starting page: This field is the first page, starting from which results will be obtained.
[ "Given", "starting", "API", "query", "for", "Open", "Humans", "iterate", "to", "get", "all", "results", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L116-L138
OpenHumans/open-humans-api
ohapi/api.py
exchange_oauth2_member
def exchange_oauth2_member(access_token, base_url=OH_BASE_URL, all_files=False): """ Returns data for a specific user, including shared data files. :param access_token: This field is the user specific access_token. :param base_url: It is this URL `https://www.openhumans.org`....
python
def exchange_oauth2_member(access_token, base_url=OH_BASE_URL, all_files=False): """ Returns data for a specific user, including shared data files. :param access_token: This field is the user specific access_token. :param base_url: It is this URL `https://www.openhumans.org`....
[ "def", "exchange_oauth2_member", "(", "access_token", ",", "base_url", "=", "OH_BASE_URL", ",", "all_files", "=", "False", ")", ":", "url", "=", "urlparse", ".", "urljoin", "(", "base_url", ",", "'/api/direct-sharing/project/exchange-member/?{}'", ".", "format", "("...
Returns data for a specific user, including shared data files. :param access_token: This field is the user specific access_token. :param base_url: It is this URL `https://www.openhumans.org`.
[ "Returns", "data", "for", "a", "specific", "user", "including", "shared", "data", "files", "." ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L141-L164
OpenHumans/open-humans-api
ohapi/api.py
delete_file
def delete_file(access_token, project_member_id=None, base_url=OH_BASE_URL, file_basename=None, file_id=None, all_files=False): """ Delete project member files by file_basename, file_id, or all_files. To learn more about Open Humans OAuth2 projects, go to: https://www.openhumans....
python
def delete_file(access_token, project_member_id=None, base_url=OH_BASE_URL, file_basename=None, file_id=None, all_files=False): """ Delete project member files by file_basename, file_id, or all_files. To learn more about Open Humans OAuth2 projects, go to: https://www.openhumans....
[ "def", "delete_file", "(", "access_token", ",", "project_member_id", "=", "None", ",", "base_url", "=", "OH_BASE_URL", ",", "file_basename", "=", "None", ",", "file_id", "=", "None", ",", "all_files", "=", "False", ")", ":", "url", "=", "urlparse", ".", "u...
Delete project member files by file_basename, file_id, or all_files. To learn more about Open Humans OAuth2 projects, go to: https://www.openhumans.org/direct-sharing/oauth2-features/. :param access_token: This field is user specific access_token. :param project_member_id: This field is the pro...
[ "Delete", "project", "member", "files", "by", "file_basename", "file_id", "or", "all_files", ".", "To", "learn", "more", "about", "Open", "Humans", "OAuth2", "projects", "go", "to", ":", "https", ":", "//", "www", ".", "openhumans", ".", "org", "/", "direc...
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L166-L203
OpenHumans/open-humans-api
ohapi/api.py
message
def message(subject, message, access_token, all_members=False, project_member_ids=None, base_url=OH_BASE_URL): """ Send an email to individual users or in bulk. To learn more about Open Humans OAuth2 projects, go to: https://www.openhumans.org/direct-sharing/oauth2-features/ :param subj...
python
def message(subject, message, access_token, all_members=False, project_member_ids=None, base_url=OH_BASE_URL): """ Send an email to individual users or in bulk. To learn more about Open Humans OAuth2 projects, go to: https://www.openhumans.org/direct-sharing/oauth2-features/ :param subj...
[ "def", "message", "(", "subject", ",", "message", ",", "access_token", ",", "all_members", "=", "False", ",", "project_member_ids", "=", "None", ",", "base_url", "=", "OH_BASE_URL", ")", ":", "url", "=", "urlparse", ".", "urljoin", "(", "base_url", ",", "'...
Send an email to individual users or in bulk. To learn more about Open Humans OAuth2 projects, go to: https://www.openhumans.org/direct-sharing/oauth2-features/ :param subject: This field is the subject of the email. :param message: This field is the body of the email. :param access_token: This is ...
[ "Send", "an", "email", "to", "individual", "users", "or", "in", "bulk", ".", "To", "learn", "more", "about", "Open", "Humans", "OAuth2", "projects", "go", "to", ":", "https", ":", "//", "www", ".", "openhumans", ".", "org", "/", "direct", "-", "sharing...
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L214-L247
OpenHumans/open-humans-api
ohapi/api.py
handle_error
def handle_error(r, expected_code): """ Helper function to match reponse of a request to the expected status code :param r: This field is the response of request. :param expected_code: This field is the expected status code for the function. """ code = r.status_code if code != e...
python
def handle_error(r, expected_code): """ Helper function to match reponse of a request to the expected status code :param r: This field is the response of request. :param expected_code: This field is the expected status code for the function. """ code = r.status_code if code != e...
[ "def", "handle_error", "(", "r", ",", "expected_code", ")", ":", "code", "=", "r", ".", "status_code", "if", "code", "!=", "expected_code", ":", "info", "=", "'API response status code {}'", ".", "format", "(", "code", ")", "try", ":", "if", "'detail'", "i...
Helper function to match reponse of a request to the expected status code :param r: This field is the response of request. :param expected_code: This field is the expected status code for the function.
[ "Helper", "function", "to", "match", "reponse", "of", "a", "request", "to", "the", "expected", "status", "code" ]
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L258-L277
OpenHumans/open-humans-api
ohapi/api.py
upload_stream
def upload_stream(stream, filename, metadata, access_token, base_url=OH_BASE_URL, remote_file_info=None, project_member_id=None, max_bytes=MAX_FILE_DEFAULT, file_identifier=None): """ Upload a file object using the "direct upload" feature, which uploads to ...
python
def upload_stream(stream, filename, metadata, access_token, base_url=OH_BASE_URL, remote_file_info=None, project_member_id=None, max_bytes=MAX_FILE_DEFAULT, file_identifier=None): """ Upload a file object using the "direct upload" feature, which uploads to ...
[ "def", "upload_stream", "(", "stream", ",", "filename", ",", "metadata", ",", "access_token", ",", "base_url", "=", "OH_BASE_URL", ",", "remote_file_info", "=", "None", ",", "project_member_id", "=", "None", ",", "max_bytes", "=", "MAX_FILE_DEFAULT", ",", "file_...
Upload a file object using the "direct upload" feature, which uploads to an S3 bucket URL provided by the Open Humans API. To learn more about this API endpoint see: * https://www.openhumans.org/direct-sharing/on-site-data-upload/ * https://www.openhumans.org/direct-sharing/oauth2-data-upload/ :par...
[ "Upload", "a", "file", "object", "using", "the", "direct", "upload", "feature", "which", "uploads", "to", "an", "S3", "bucket", "URL", "provided", "by", "the", "Open", "Humans", "API", ".", "To", "learn", "more", "about", "this", "API", "endpoint", "see", ...
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L280-L355
OpenHumans/open-humans-api
ohapi/api.py
upload_file
def upload_file(target_filepath, metadata, access_token, base_url=OH_BASE_URL, remote_file_info=None, project_member_id=None, max_bytes=MAX_FILE_DEFAULT): """ Upload a file from a local filepath using the "direct upload" API. To learn more about this API endpoint see: * h...
python
def upload_file(target_filepath, metadata, access_token, base_url=OH_BASE_URL, remote_file_info=None, project_member_id=None, max_bytes=MAX_FILE_DEFAULT): """ Upload a file from a local filepath using the "direct upload" API. To learn more about this API endpoint see: * h...
[ "def", "upload_file", "(", "target_filepath", ",", "metadata", ",", "access_token", ",", "base_url", "=", "OH_BASE_URL", ",", "remote_file_info", "=", "None", ",", "project_member_id", "=", "None", ",", "max_bytes", "=", "MAX_FILE_DEFAULT", ")", ":", "with", "op...
Upload a file from a local filepath using the "direct upload" API. To learn more about this API endpoint see: * https://www.openhumans.org/direct-sharing/on-site-data-upload/ * https://www.openhumans.org/direct-sharing/oauth2-data-upload/ :param target_filepath: This field is the filepath of the file t...
[ "Upload", "a", "file", "from", "a", "local", "filepath", "using", "the", "direct", "upload", "API", ".", "To", "learn", "more", "about", "this", "API", "endpoint", "see", ":", "*", "https", ":", "//", "www", ".", "openhumans", ".", "org", "/", "direct"...
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L358-L385
OpenHumans/open-humans-api
ohapi/api.py
upload_aws
def upload_aws(target_filepath, metadata, access_token, base_url=OH_BASE_URL, remote_file_info=None, project_member_id=None, max_bytes=MAX_FILE_DEFAULT): """ Upload a file from a local filepath using the "direct upload" API. Equivalent to upload_file. To learn more about this A...
python
def upload_aws(target_filepath, metadata, access_token, base_url=OH_BASE_URL, remote_file_info=None, project_member_id=None, max_bytes=MAX_FILE_DEFAULT): """ Upload a file from a local filepath using the "direct upload" API. Equivalent to upload_file. To learn more about this A...
[ "def", "upload_aws", "(", "target_filepath", ",", "metadata", ",", "access_token", ",", "base_url", "=", "OH_BASE_URL", ",", "remote_file_info", "=", "None", ",", "project_member_id", "=", "None", ",", "max_bytes", "=", "MAX_FILE_DEFAULT", ")", ":", "return", "u...
Upload a file from a local filepath using the "direct upload" API. Equivalent to upload_file. To learn more about this API endpoint see: * https://www.openhumans.org/direct-sharing/on-site-data-upload/ * https://www.openhumans.org/direct-sharing/oauth2-data-upload/ :param target_filepath: This field is...
[ "Upload", "a", "file", "from", "a", "local", "filepath", "using", "the", "direct", "upload", "API", ".", "Equivalent", "to", "upload_file", ".", "To", "learn", "more", "about", "this", "API", "endpoint", "see", ":", "*", "https", ":", "//", "www", ".", ...
train
https://github.com/OpenHumans/open-humans-api/blob/ca2a28cf5d55cfdae13dd222ba58c25565bdb86e/ohapi/api.py#L388-L411
tych0/xcffib
module/__init__.py
pack_list
def pack_list(from_, pack_type): """ Return the wire packed version of `from_`. `pack_type` should be some subclass of `xcffib.Struct`, or a string that can be passed to `struct.pack`. You must pass `size` if `pack_type` is a struct.pack string. """ # We need from_ to not be empty if len(from_) ...
python
def pack_list(from_, pack_type): """ Return the wire packed version of `from_`. `pack_type` should be some subclass of `xcffib.Struct`, or a string that can be passed to `struct.pack`. You must pass `size` if `pack_type` is a struct.pack string. """ # We need from_ to not be empty if len(from_) ...
[ "def", "pack_list", "(", "from_", ",", "pack_type", ")", ":", "# We need from_ to not be empty", "if", "len", "(", "from_", ")", "==", "0", ":", "return", "bytes", "(", ")", "if", "pack_type", "==", "'c'", ":", "if", "isinstance", "(", "from_", ",", "byt...
Return the wire packed version of `from_`. `pack_type` should be some subclass of `xcffib.Struct`, or a string that can be passed to `struct.pack`. You must pass `size` if `pack_type` is a struct.pack string.
[ "Return", "the", "wire", "packed", "version", "of", "from_", ".", "pack_type", "should", "be", "some", "subclass", "of", "xcffib", ".", "Struct", "or", "a", "string", "that", "can", "be", "passed", "to", "struct", ".", "pack", ".", "You", "must", "pass",...
train
https://github.com/tych0/xcffib/blob/c9c50c3ce513b130821f430be78c4c733626c707/module/__init__.py#L751-L793
tych0/xcffib
module/__init__.py
Connection.ensure_connected
def ensure_connected(f): """ Check that the connection is valid both before and after the function is invoked. """ @functools.wraps(f) def wrapper(*args): self = args[0] self.invalid() try: return f(*args) fi...
python
def ensure_connected(f): """ Check that the connection is valid both before and after the function is invoked. """ @functools.wraps(f) def wrapper(*args): self = args[0] self.invalid() try: return f(*args) fi...
[ "def", "ensure_connected", "(", "f", ")", ":", "@", "functools", ".", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ")", ":", "self", "=", "args", "[", "0", "]", "self", ".", "invalid", "(", ")", "try", ":", "return", "f", "(", "*...
Check that the connection is valid both before and after the function is invoked.
[ "Check", "that", "the", "connection", "is", "valid", "both", "before", "and", "after", "the", "function", "is", "invoked", "." ]
train
https://github.com/tych0/xcffib/blob/c9c50c3ce513b130821f430be78c4c733626c707/module/__init__.py#L560-L573
tych0/xcffib
module/__init__.py
Connection.get_screen_pointers
def get_screen_pointers(self): """ Returns the xcb_screen_t for every screen useful for other bindings """ root_iter = lib.xcb_setup_roots_iterator(self._setup) screens = [root_iter.data] for i in range(self._setup.roots_len - 1): lib.xcb_screen_next(...
python
def get_screen_pointers(self): """ Returns the xcb_screen_t for every screen useful for other bindings """ root_iter = lib.xcb_setup_roots_iterator(self._setup) screens = [root_iter.data] for i in range(self._setup.roots_len - 1): lib.xcb_screen_next(...
[ "def", "get_screen_pointers", "(", "self", ")", ":", "root_iter", "=", "lib", ".", "xcb_setup_roots_iterator", "(", "self", ".", "_setup", ")", "screens", "=", "[", "root_iter", ".", "data", "]", "for", "i", "in", "range", "(", "self", ".", "_setup", "."...
Returns the xcb_screen_t for every screen useful for other bindings
[ "Returns", "the", "xcb_screen_t", "for", "every", "screen", "useful", "for", "other", "bindings" ]
train
https://github.com/tych0/xcffib/blob/c9c50c3ce513b130821f430be78c4c733626c707/module/__init__.py#L586-L597
tych0/xcffib
module/__init__.py
Connection.hoist_event
def hoist_event(self, e): """ Hoist an xcb_generic_event_t to the right xcffib structure. """ if e.response_type == 0: return self._process_error(ffi.cast("xcb_generic_error_t *", e)) # We mask off the high bit here because events sent with SendEvent have # this bit set. We ...
python
def hoist_event(self, e): """ Hoist an xcb_generic_event_t to the right xcffib structure. """ if e.response_type == 0: return self._process_error(ffi.cast("xcb_generic_error_t *", e)) # We mask off the high bit here because events sent with SendEvent have # this bit set. We ...
[ "def", "hoist_event", "(", "self", ",", "e", ")", ":", "if", "e", ".", "response_type", "==", "0", ":", "return", "self", ".", "_process_error", "(", "ffi", ".", "cast", "(", "\"xcb_generic_error_t *\"", ",", "e", ")", ")", "# We mask off the high bit here b...
Hoist an xcb_generic_event_t to the right xcffib structure.
[ "Hoist", "an", "xcb_generic_event_t", "to", "the", "right", "xcffib", "structure", "." ]
train
https://github.com/tych0/xcffib/blob/c9c50c3ce513b130821f430be78c4c733626c707/module/__init__.py#L681-L693
debrouwere/google-analytics
googleanalytics/columns.py
ColumnList.serialize
def serialize(self, value, greedy=True): """ Greedy serialization requires the value to either be a column or convertible to a column, whereas non-greedy serialization will pass through any string as-is and will only serialize Column objects. Non-greedy serialization is ...
python
def serialize(self, value, greedy=True): """ Greedy serialization requires the value to either be a column or convertible to a column, whereas non-greedy serialization will pass through any string as-is and will only serialize Column objects. Non-greedy serialization is ...
[ "def", "serialize", "(", "self", ",", "value", ",", "greedy", "=", "True", ")", ":", "if", "greedy", "and", "not", "isinstance", "(", "value", ",", "Column", ")", ":", "value", "=", "self", ".", "normalize", "(", "value", ")", "if", "isinstance", "("...
Greedy serialization requires the value to either be a column or convertible to a column, whereas non-greedy serialization will pass through any string as-is and will only serialize Column objects. Non-greedy serialization is useful when preparing queries with custom filters or ...
[ "Greedy", "serialization", "requires", "the", "value", "to", "either", "be", "a", "column", "or", "convertible", "to", "a", "column", "whereas", "non", "-", "greedy", "serialization", "will", "pass", "through", "any", "string", "as", "-", "is", "and", "will"...
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/columns.py#L237-L254
debrouwere/google-analytics
googleanalytics/query.py
describe
def describe(profile, description): """ Generate a query by describing it as a series of actions and parameters to those actions. These map directly to Query methods and arguments to those methods. This is an alternative to the chaining interface. Mostly useful if you'd like to put your queries...
python
def describe(profile, description): """ Generate a query by describing it as a series of actions and parameters to those actions. These map directly to Query methods and arguments to those methods. This is an alternative to the chaining interface. Mostly useful if you'd like to put your queries...
[ "def", "describe", "(", "profile", ",", "description", ")", ":", "api_type", "=", "description", ".", "pop", "(", "'type'", ",", "'core'", ")", "api", "=", "getattr", "(", "profile", ",", "api_type", ")", "return", "refine", "(", "api", ".", "query", "...
Generate a query by describing it as a series of actions and parameters to those actions. These map directly to Query methods and arguments to those methods. This is an alternative to the chaining interface. Mostly useful if you'd like to put your queries in a file, rather than in Python code.
[ "Generate", "a", "query", "by", "describing", "it", "as", "a", "series", "of", "actions", "and", "parameters", "to", "those", "actions", ".", "These", "map", "directly", "to", "Query", "methods", "and", "arguments", "to", "those", "methods", "." ]
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L1093-L1105
debrouwere/google-analytics
googleanalytics/query.py
refine
def refine(query, description): """ Refine a query from a dictionary of parameters that describes it. See `describe` for more information. """ for attribute, arguments in description.items(): if hasattr(query, attribute): attribute = getattr(query, attribute) else: ...
python
def refine(query, description): """ Refine a query from a dictionary of parameters that describes it. See `describe` for more information. """ for attribute, arguments in description.items(): if hasattr(query, attribute): attribute = getattr(query, attribute) else: ...
[ "def", "refine", "(", "query", ",", "description", ")", ":", "for", "attribute", ",", "arguments", "in", "description", ".", "items", "(", ")", ":", "if", "hasattr", "(", "query", ",", "attribute", ")", ":", "attribute", "=", "getattr", "(", "query", "...
Refine a query from a dictionary of parameters that describes it. See `describe` for more information.
[ "Refine", "a", "query", "from", "a", "dictionary", "of", "parameters", "that", "describes", "it", ".", "See", "describe", "for", "more", "information", "." ]
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L1107-L1135
debrouwere/google-analytics
googleanalytics/query.py
Query.set
def set(self, key=None, value=None, **kwargs): """ `set` is a way to add raw properties to the request, for features that this module does not support or supports incompletely. For convenience's sake, it will serialize Column objects but will leave any other kind of value...
python
def set(self, key=None, value=None, **kwargs): """ `set` is a way to add raw properties to the request, for features that this module does not support or supports incompletely. For convenience's sake, it will serialize Column objects but will leave any other kind of value...
[ "def", "set", "(", "self", ",", "key", "=", "None", ",", "value", "=", "None", ",", "*", "*", "kwargs", ")", ":", "serialize", "=", "partial", "(", "self", ".", "api", ".", "columns", ".", "serialize", ",", "greedy", "=", "False", ")", "if", "key...
`set` is a way to add raw properties to the request, for features that this module does not support or supports incompletely. For convenience's sake, it will serialize Column objects but will leave any other kind of value alone.
[ "set", "is", "a", "way", "to", "add", "raw", "properties", "to", "the", "request", "for", "features", "that", "this", "module", "does", "not", "support", "or", "supports", "incompletely", ".", "For", "convenience", "s", "sake", "it", "will", "serialize", "...
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L430-L451
debrouwere/google-analytics
googleanalytics/query.py
Query.description
def description(self): """ A list of the metrics this query will ask for. """ if 'metrics' in self.raw: metrics = self.raw['metrics'] head = metrics[0:-1] or metrics[0:1] text = ", ".join(head) if len(metrics) > 1: tail = m...
python
def description(self): """ A list of the metrics this query will ask for. """ if 'metrics' in self.raw: metrics = self.raw['metrics'] head = metrics[0:-1] or metrics[0:1] text = ", ".join(head) if len(metrics) > 1: tail = m...
[ "def", "description", "(", "self", ")", ":", "if", "'metrics'", "in", "self", ".", "raw", ":", "metrics", "=", "self", ".", "raw", "[", "'metrics'", "]", "head", "=", "metrics", "[", "0", ":", "-", "1", "]", "or", "metrics", "[", "0", ":", "1", ...
A list of the metrics this query will ask for.
[ "A", "list", "of", "the", "metrics", "this", "query", "will", "ask", "for", "." ]
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L469-L484
debrouwere/google-analytics
googleanalytics/query.py
Query.sort
def sort(self, *columns, **options): """ Return a new query which will produce results sorted by one or more metrics or dimensions. You may use plain strings for the columns, or actual `Column`, `Metric` and `Dimension` objects. Add a minus in front of the metric (either...
python
def sort(self, *columns, **options): """ Return a new query which will produce results sorted by one or more metrics or dimensions. You may use plain strings for the columns, or actual `Column`, `Metric` and `Dimension` objects. Add a minus in front of the metric (either...
[ "def", "sort", "(", "self", ",", "*", "columns", ",", "*", "*", "options", ")", ":", "sorts", "=", "self", ".", "meta", ".", "setdefault", "(", "'sort'", ",", "[", "]", ")", "for", "column", "in", "columns", ":", "if", "isinstance", "(", "column", ...
Return a new query which will produce results sorted by one or more metrics or dimensions. You may use plain strings for the columns, or actual `Column`, `Metric` and `Dimension` objects. Add a minus in front of the metric (either the string or the object) to sort in descending ...
[ "Return", "a", "new", "query", "which", "will", "produce", "results", "sorted", "by", "one", "or", "more", "metrics", "or", "dimensions", ".", "You", "may", "use", "plain", "strings", "for", "the", "columns", "or", "actual", "Column", "Metric", "and", "Dim...
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L515-L556
debrouwere/google-analytics
googleanalytics/query.py
Query.filter
def filter(self, value=None, exclude=False, **selection): """ Most of the actual functionality lives on the Column object and the `all` and `any` functions. """ filters = self.meta.setdefault('filters', []) if value and len(selection): raise ValueError("Cannot specify a filt...
python
def filter(self, value=None, exclude=False, **selection): """ Most of the actual functionality lives on the Column object and the `all` and `any` functions. """ filters = self.meta.setdefault('filters', []) if value and len(selection): raise ValueError("Cannot specify a filt...
[ "def", "filter", "(", "self", ",", "value", "=", "None", ",", "exclude", "=", "False", ",", "*", "*", "selection", ")", ":", "filters", "=", "self", ".", "meta", ".", "setdefault", "(", "'filters'", ",", "[", "]", ")", "if", "value", "and", "len", ...
Most of the actual functionality lives on the Column object and the `all` and `any` functions.
[ "Most", "of", "the", "actual", "functionality", "lives", "on", "the", "Column", "object", "and", "the", "all", "and", "any", "functions", "." ]
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L559-L573
debrouwere/google-analytics
googleanalytics/query.py
CoreQuery.precision
def precision(self, precision): """ For queries that should run faster, you may specify a lower precision, and for those that need to be more precise, a higher precision: ```python # faster queries query.range('2014-01-01', '2014-01-31', precision=0) query.range(...
python
def precision(self, precision): """ For queries that should run faster, you may specify a lower precision, and for those that need to be more precise, a higher precision: ```python # faster queries query.range('2014-01-01', '2014-01-31', precision=0) query.range(...
[ "def", "precision", "(", "self", ",", "precision", ")", ":", "if", "isinstance", "(", "precision", ",", "int", ")", ":", "precision", "=", "self", ".", "PRECISION_LEVELS", "[", "precision", "]", "if", "precision", "not", "in", "self", ".", "PRECISION_LEVEL...
For queries that should run faster, you may specify a lower precision, and for those that need to be more precise, a higher precision: ```python # faster queries query.range('2014-01-01', '2014-01-31', precision=0) query.range('2014-01-01', '2014-01-31', precision='FASTER') ...
[ "For", "queries", "that", "should", "run", "faster", "you", "may", "specify", "a", "lower", "precision", "and", "for", "those", "that", "need", "to", "be", "more", "precise", "a", "higher", "precision", ":" ]
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L702-L731
debrouwere/google-analytics
googleanalytics/query.py
CoreQuery.interval
def interval(self, granularity): """ Note that if you don't specify a granularity (either through the `interval` method or through the `hourly`, `daily`, `weekly`, `monthly` or `yearly` shortcut methods) you will get only a single result, encompassing the entire date range, per m...
python
def interval(self, granularity): """ Note that if you don't specify a granularity (either through the `interval` method or through the `hourly`, `daily`, `weekly`, `monthly` or `yearly` shortcut methods) you will get only a single result, encompassing the entire date range, per m...
[ "def", "interval", "(", "self", ",", "granularity", ")", ":", "if", "granularity", "==", "'total'", ":", "return", "self", "if", "not", "isinstance", "(", "granularity", ",", "int", ")", ":", "if", "granularity", "in", "self", ".", "GRANULARITY_LEVELS", ":...
Note that if you don't specify a granularity (either through the `interval` method or through the `hourly`, `daily`, `weekly`, `monthly` or `yearly` shortcut methods) you will get only a single result, encompassing the entire date range, per metric.
[ "Note", "that", "if", "you", "don", "t", "specify", "a", "granularity", "(", "either", "through", "the", "interval", "method", "or", "through", "the", "hourly", "daily", "weekly", "monthly", "or", "yearly", "shortcut", "methods", ")", "you", "will", "get", ...
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L734-L755
debrouwere/google-analytics
googleanalytics/query.py
CoreQuery.range
def range(self, start=None, stop=None, months=0, days=0): """ Return a new query that fetches metrics within a certain date range. ```python query.range('2014-01-01', '2014-06-30') ``` If you don't specify a `stop` argument, the date range will end today. If instead ...
python
def range(self, start=None, stop=None, months=0, days=0): """ Return a new query that fetches metrics within a certain date range. ```python query.range('2014-01-01', '2014-06-30') ``` If you don't specify a `stop` argument, the date range will end today. If instead ...
[ "def", "range", "(", "self", ",", "start", "=", "None", ",", "stop", "=", "None", ",", "months", "=", "0", ",", "days", "=", "0", ")", ":", "start", ",", "stop", "=", "utils", ".", "date", ".", "range", "(", "start", ",", "stop", ",", "months",...
Return a new query that fetches metrics within a certain date range. ```python query.range('2014-01-01', '2014-06-30') ``` If you don't specify a `stop` argument, the date range will end today. If instead you meant to fetch just a single day's results, try: ```python ...
[ "Return", "a", "new", "query", "that", "fetches", "metrics", "within", "a", "certain", "date", "range", "." ]
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L758-L798
debrouwere/google-analytics
googleanalytics/query.py
CoreQuery.limit
def limit(self, *_range): """ Return a new query, limited to a certain number of results. ```python # first 100 query.limit(100) # 50 to 60 query.limit(50, 10) ``` Please note carefully that Google Analytics uses 1-indexing on its rows. ...
python
def limit(self, *_range): """ Return a new query, limited to a certain number of results. ```python # first 100 query.limit(100) # 50 to 60 query.limit(50, 10) ``` Please note carefully that Google Analytics uses 1-indexing on its rows. ...
[ "def", "limit", "(", "self", ",", "*", "_range", ")", ":", "# uses the same argument order as", "# LIMIT in a SQL database", "if", "len", "(", "_range", ")", "==", "2", ":", "start", ",", "maximum", "=", "_range", "else", ":", "start", "=", "1", "maximum", ...
Return a new query, limited to a certain number of results. ```python # first 100 query.limit(100) # 50 to 60 query.limit(50, 10) ``` Please note carefully that Google Analytics uses 1-indexing on its rows.
[ "Return", "a", "new", "query", "limited", "to", "a", "certain", "number", "of", "results", "." ]
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L866-L895
debrouwere/google-analytics
googleanalytics/query.py
CoreQuery.segment
def segment(self, value=None, scope=None, metric_scope=None, **selection): """ Return a new query, limited to a segment of all users or sessions. Accepts segment objects, filtered segment objects and segment names: ```python query.segment(account.segments['browser']) qu...
python
def segment(self, value=None, scope=None, metric_scope=None, **selection): """ Return a new query, limited to a segment of all users or sessions. Accepts segment objects, filtered segment objects and segment names: ```python query.segment(account.segments['browser']) qu...
[ "def", "segment", "(", "self", ",", "value", "=", "None", ",", "scope", "=", "None", ",", "metric_scope", "=", "None", ",", "*", "*", "selection", ")", ":", "\"\"\"\n Technical note to self about segments:\n\n * users or sessions\n * sequence or condi...
Return a new query, limited to a segment of all users or sessions. Accepts segment objects, filtered segment objects and segment names: ```python query.segment(account.segments['browser']) query.segment('browser') query.segment(account.segments['browser'].any('Chrome', 'Firefox...
[ "Return", "a", "new", "query", "limited", "to", "a", "segment", "of", "all", "users", "or", "sessions", "." ]
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L909-L1003
debrouwere/google-analytics
googleanalytics/query.py
CoreQuery.next
def next(self): """ Return a new query with a modified `start_index`. Mainly used internally to paginate through results. """ step = self.raw.get('max_results', 1000) start = self.raw.get('start_index', 1) + step self.raw['start_index'] = start return self
python
def next(self): """ Return a new query with a modified `start_index`. Mainly used internally to paginate through results. """ step = self.raw.get('max_results', 1000) start = self.raw.get('start_index', 1) + step self.raw['start_index'] = start return self
[ "def", "next", "(", "self", ")", ":", "step", "=", "self", ".", "raw", ".", "get", "(", "'max_results'", ",", "1000", ")", "start", "=", "self", ".", "raw", ".", "get", "(", "'start_index'", ",", "1", ")", "+", "step", "self", ".", "raw", "[", ...
Return a new query with a modified `start_index`. Mainly used internally to paginate through results.
[ "Return", "a", "new", "query", "with", "a", "modified", "start_index", ".", "Mainly", "used", "internally", "to", "paginate", "through", "results", "." ]
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L1012-L1020
debrouwere/google-analytics
googleanalytics/query.py
CoreQuery.get
def get(self): """ Run the query and return a `Report`. This method transparently handles paginated results, so even for results that are larger than the maximum amount of rows the Google Analytics API will return in a single request, or larger than the amount of rows as specifi...
python
def get(self): """ Run the query and return a `Report`. This method transparently handles paginated results, so even for results that are larger than the maximum amount of rows the Google Analytics API will return in a single request, or larger than the amount of rows as specifi...
[ "def", "get", "(", "self", ")", ":", "cursor", "=", "self", "report", "=", "None", "is_complete", "=", "False", "is_enough", "=", "False", "while", "not", "(", "is_enough", "or", "is_complete", ")", ":", "chunk", "=", "cursor", ".", "execute", "(", ")"...
Run the query and return a `Report`. This method transparently handles paginated results, so even for results that are larger than the maximum amount of rows the Google Analytics API will return in a single request, or larger than the amount of rows as specified through `CoreQuery#step`...
[ "Run", "the", "query", "and", "return", "a", "Report", "." ]
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L1022-L1050
debrouwere/google-analytics
googleanalytics/query.py
RealTimeQuery.limit
def limit(self, maximum): """ Return a new query, limited to a certain number of results. Unlike core reporting queries, you cannot specify a starting point for live queries, just the maximum results returned. ```python # first 50 query.limit(50) ``` ...
python
def limit(self, maximum): """ Return a new query, limited to a certain number of results. Unlike core reporting queries, you cannot specify a starting point for live queries, just the maximum results returned. ```python # first 50 query.limit(50) ``` ...
[ "def", "limit", "(", "self", ",", "maximum", ")", ":", "self", ".", "meta", "[", "'limit'", "]", "=", "maximum", "self", ".", "raw", ".", "update", "(", "{", "'max_results'", ":", "maximum", ",", "}", ")", "return", "self" ]
Return a new query, limited to a certain number of results. Unlike core reporting queries, you cannot specify a starting point for live queries, just the maximum results returned. ```python # first 50 query.limit(50) ```
[ "Return", "a", "new", "query", "limited", "to", "a", "certain", "number", "of", "results", "." ]
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/query.py#L1068-L1085
debrouwere/google-analytics
googleanalytics/auth/credentials.py
Credentials.valid
def valid(self): """ Valid credentials are not necessarily correct, but they contain all necessary information for an authentication attempt. """ two_legged = self.client_email and self.private_key three_legged = self.client_id and self.client_secret return two_legged or ...
python
def valid(self): """ Valid credentials are not necessarily correct, but they contain all necessary information for an authentication attempt. """ two_legged = self.client_email and self.private_key three_legged = self.client_id and self.client_secret return two_legged or ...
[ "def", "valid", "(", "self", ")", ":", "two_legged", "=", "self", ".", "client_email", "and", "self", ".", "private_key", "three_legged", "=", "self", ".", "client_id", "and", "self", ".", "client_secret", "return", "two_legged", "or", "three_legged", "or", ...
Valid credentials are not necessarily correct, but they contain all necessary information for an authentication attempt.
[ "Valid", "credentials", "are", "not", "necessarily", "correct", "but", "they", "contain", "all", "necessary", "information", "for", "an", "authentication", "attempt", "." ]
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/auth/credentials.py#L136-L142
debrouwere/google-analytics
googleanalytics/auth/credentials.py
Credentials.complete
def complete(self): """ Complete credentials are valid and are either two-legged or include a token. """ return self.valid and (self.access_token or self.refresh_token or self.type == 2)
python
def complete(self): """ Complete credentials are valid and are either two-legged or include a token. """ return self.valid and (self.access_token or self.refresh_token or self.type == 2)
[ "def", "complete", "(", "self", ")", ":", "return", "self", ".", "valid", "and", "(", "self", ".", "access_token", "or", "self", ".", "refresh_token", "or", "self", ".", "type", "==", "2", ")" ]
Complete credentials are valid and are either two-legged or include a token.
[ "Complete", "credentials", "are", "valid", "and", "are", "either", "two", "-", "legged", "or", "include", "a", "token", "." ]
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/auth/credentials.py#L149-L151
debrouwere/google-analytics
googleanalytics/auth/__init__.py
authenticate
def authenticate( client_id=None, client_secret=None, client_email=None, private_key=None, access_token=None, refresh_token=None, account=None, webproperty=None, profile=None, identity=None, prefix=None, suffix=None, interactive=False, save=False): """ The `authen...
python
def authenticate( client_id=None, client_secret=None, client_email=None, private_key=None, access_token=None, refresh_token=None, account=None, webproperty=None, profile=None, identity=None, prefix=None, suffix=None, interactive=False, save=False): """ The `authen...
[ "def", "authenticate", "(", "client_id", "=", "None", ",", "client_secret", "=", "None", ",", "client_email", "=", "None", ",", "private_key", "=", "None", ",", "access_token", "=", "None", ",", "refresh_token", "=", "None", ",", "account", "=", "None", ",...
The `authenticate` function will authenticate the user with the Google Analytics API, using a variety of strategies: keyword arguments provided to this function, credentials stored in in environment variables, credentials stored in the keychain and, finally, by asking for missing information interactively i...
[ "The", "authenticate", "function", "will", "authenticate", "the", "user", "with", "the", "Google", "Analytics", "API", "using", "a", "variety", "of", "strategies", ":", "keyword", "arguments", "provided", "to", "this", "function", "credentials", "stored", "in", ...
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/auth/__init__.py#L43-L97
debrouwere/google-analytics
googleanalytics/auth/__init__.py
revoke
def revoke(client_id, client_secret, client_email=None, private_key=None, access_token=None, refresh_token=None, identity=None, prefix=None, suffix=None): """ Given a client id, client secret and either an access token or a refresh token, revoke OAuth access to the Google Analytics ...
python
def revoke(client_id, client_secret, client_email=None, private_key=None, access_token=None, refresh_token=None, identity=None, prefix=None, suffix=None): """ Given a client id, client secret and either an access token or a refresh token, revoke OAuth access to the Google Analytics ...
[ "def", "revoke", "(", "client_id", ",", "client_secret", ",", "client_email", "=", "None", ",", "private_key", "=", "None", ",", "access_token", "=", "None", ",", "refresh_token", "=", "None", ",", "identity", "=", "None", ",", "prefix", "=", "None", ",", ...
Given a client id, client secret and either an access token or a refresh token, revoke OAuth access to the Google Analytics data and remove any stored credentials that use these tokens.
[ "Given", "a", "client", "id", "client", "secret", "and", "either", "an", "access", "token", "or", "a", "refresh", "token", "revoke", "OAuth", "access", "to", "the", "Google", "Analytics", "data", "and", "remove", "any", "stored", "credentials", "that", "use"...
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/auth/__init__.py#L123-L151
debrouwere/google-analytics
googleanalytics/commands/query.py
query
def query(scope, blueprint, debug, output, with_metadata, realtime, **description): """ e.g. googleanalytics --identity debrouwere --account debrouwere --webproperty http://debrouwere.org \ query pageviews \ --start yesterday --limit -10 --sort -pageviews \ --dimensi...
python
def query(scope, blueprint, debug, output, with_metadata, realtime, **description): """ e.g. googleanalytics --identity debrouwere --account debrouwere --webproperty http://debrouwere.org \ query pageviews \ --start yesterday --limit -10 --sort -pageviews \ --dimensi...
[ "def", "query", "(", "scope", ",", "blueprint", ",", "debug", ",", "output", ",", "with_metadata", ",", "realtime", ",", "*", "*", "description", ")", ":", "if", "realtime", ":", "description", "[", "'type'", "]", "=", "'realtime'", "if", "blueprint", ":...
e.g. googleanalytics --identity debrouwere --account debrouwere --webproperty http://debrouwere.org \ query pageviews \ --start yesterday --limit -10 --sort -pageviews \ --dimensions pagepath \ --debug
[ "e", ".", "g", "." ]
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/commands/query.py#L102-L130
debrouwere/google-analytics
googleanalytics/utils/functional.py
vectorize
def vectorize(fn): """ Allows a method to accept one or more values, but internally deal only with a single item, and returning a list or a single item depending on what is desired. """ @functools.wraps(fn) def vectorized_method(self, values, *vargs, **kwargs): wrap = not isinst...
python
def vectorize(fn): """ Allows a method to accept one or more values, but internally deal only with a single item, and returning a list or a single item depending on what is desired. """ @functools.wraps(fn) def vectorized_method(self, values, *vargs, **kwargs): wrap = not isinst...
[ "def", "vectorize", "(", "fn", ")", ":", "@", "functools", ".", "wraps", "(", "fn", ")", "def", "vectorized_method", "(", "self", ",", "values", ",", "*", "vargs", ",", "*", "*", "kwargs", ")", ":", "wrap", "=", "not", "isinstance", "(", "values", ...
Allows a method to accept one or more values, but internally deal only with a single item, and returning a list or a single item depending on what is desired.
[ "Allows", "a", "method", "to", "accept", "one", "or", "more", "values", "but", "internally", "deal", "only", "with", "a", "single", "item", "and", "returning", "a", "list", "or", "a", "single", "item", "depending", "on", "what", "is", "desired", "." ]
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/utils/functional.py#L20-L45
debrouwere/google-analytics
googleanalytics/account.py
Account.webproperties
def webproperties(self): """ A list of all web properties on this account. You may select a specific web property using its name, its id or an index. ```python account.webproperties[0] account.webproperties['UA-9234823-5'] account.webproperties['debrouwer...
python
def webproperties(self): """ A list of all web properties on this account. You may select a specific web property using its name, its id or an index. ```python account.webproperties[0] account.webproperties['UA-9234823-5'] account.webproperties['debrouwer...
[ "def", "webproperties", "(", "self", ")", ":", "raw_properties", "=", "self", ".", "service", ".", "management", "(", ")", ".", "webproperties", "(", ")", ".", "list", "(", "accountId", "=", "self", ".", "id", ")", ".", "execute", "(", ")", "[", "'it...
A list of all web properties on this account. You may select a specific web property using its name, its id or an index. ```python account.webproperties[0] account.webproperties['UA-9234823-5'] account.webproperties['debrouwere.org'] ```
[ "A", "list", "of", "all", "web", "properties", "on", "this", "account", ".", "You", "may", "select", "a", "specific", "web", "property", "using", "its", "name", "its", "id", "or", "an", "index", "." ]
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/account.py#L47-L63
debrouwere/google-analytics
googleanalytics/account.py
WebProperty.profiles
def profiles(self): """ A list of all profiles on this web property. You may select a specific profile using its name, its id or an index. ```python property.profiles[0] property.profiles['9234823'] property.profiles['marketing profile'] ``` ...
python
def profiles(self): """ A list of all profiles on this web property. You may select a specific profile using its name, its id or an index. ```python property.profiles[0] property.profiles['9234823'] property.profiles['marketing profile'] ``` ...
[ "def", "profiles", "(", "self", ")", ":", "raw_profiles", "=", "self", ".", "account", ".", "service", ".", "management", "(", ")", ".", "profiles", "(", ")", ".", "list", "(", "accountId", "=", "self", ".", "account", ".", "id", ",", "webPropertyId", ...
A list of all profiles on this web property. You may select a specific profile using its name, its id or an index. ```python property.profiles[0] property.profiles['9234823'] property.profiles['marketing profile'] ```
[ "A", "list", "of", "all", "profiles", "on", "this", "web", "property", ".", "You", "may", "select", "a", "specific", "profile", "using", "its", "name", "its", "id", "or", "an", "index", "." ]
train
https://github.com/debrouwere/google-analytics/blob/7d585c2f6f5ca191e975e6e3eaf7d5e2424fa11c/googleanalytics/account.py#L98-L114
jfilter/text-classification-keras
texcla/libs/fastTextWikiTokenizer/subprocess_fix.py
check_output_input
def check_output_input(*popenargs, **kwargs): """Run command with arguments and return its output as a byte string. If the exit code was non-zero it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute and output in the output attribute. ...
python
def check_output_input(*popenargs, **kwargs): """Run command with arguments and return its output as a byte string. If the exit code was non-zero it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute and output in the output attribute. ...
[ "def", "check_output_input", "(", "*", "popenargs", ",", "*", "*", "kwargs", ")", ":", "if", "'stdout'", "in", "kwargs", ":", "raise", "ValueError", "(", "'stdout argument not allowed, it will be overridden.'", ")", "if", "'input'", "in", "kwargs", ":", "if", "'...
Run command with arguments and return its output as a byte string. If the exit code was non-zero it raises a CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute and output in the output attribute. The arguments are the same as for the Popen construc...
[ "Run", "command", "with", "arguments", "and", "return", "its", "output", "as", "a", "byte", "string", "." ]
train
https://github.com/jfilter/text-classification-keras/blob/a59c652805da41d18937c7fdad0d9fd943cf8578/texcla/libs/fastTextWikiTokenizer/subprocess_fix.py#L7-L63