repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
alorence/django-modern-rpc
modernrpc/handlers/base.py
RPCHandler.execute_procedure
def execute_procedure(self, name, args=None, kwargs=None): """ Call the concrete python function corresponding to given RPC Method `name` and return the result. Raise RPCUnknownMethod, AuthenticationFailed, RPCInvalidParams or any Exception sub-class. """ _method = registry.get...
python
def execute_procedure(self, name, args=None, kwargs=None): """ Call the concrete python function corresponding to given RPC Method `name` and return the result. Raise RPCUnknownMethod, AuthenticationFailed, RPCInvalidParams or any Exception sub-class. """ _method = registry.get...
[ "def", "execute_procedure", "(", "self", ",", "name", ",", "args", "=", "None", ",", "kwargs", "=", "None", ")", ":", "_method", "=", "registry", ".", "get_method", "(", "name", ",", "self", ".", "entry_point", ",", "self", ".", "protocol", ")", "if", ...
Call the concrete python function corresponding to given RPC Method `name` and return the result. Raise RPCUnknownMethod, AuthenticationFailed, RPCInvalidParams or any Exception sub-class.
[ "Call", "the", "concrete", "python", "function", "corresponding", "to", "given", "RPC", "Method", "name", "and", "return", "the", "result", "." ]
train
https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/handlers/base.py#L63-L110
alorence/django-modern-rpc
modernrpc/system_methods.py
__system_listMethods
def __system_listMethods(**kwargs): """Returns a list of all methods available in the current entry point""" entry_point = kwargs.get(ENTRY_POINT_KEY) protocol = kwargs.get(PROTOCOL_KEY) return registry.get_all_method_names(entry_point, protocol, sort_methods=True)
python
def __system_listMethods(**kwargs): """Returns a list of all methods available in the current entry point""" entry_point = kwargs.get(ENTRY_POINT_KEY) protocol = kwargs.get(PROTOCOL_KEY) return registry.get_all_method_names(entry_point, protocol, sort_methods=True)
[ "def", "__system_listMethods", "(", "*", "*", "kwargs", ")", ":", "entry_point", "=", "kwargs", ".", "get", "(", "ENTRY_POINT_KEY", ")", "protocol", "=", "kwargs", ".", "get", "(", "PROTOCOL_KEY", ")", "return", "registry", ".", "get_all_method_names", "(", ...
Returns a list of all methods available in the current entry point
[ "Returns", "a", "list", "of", "all", "methods", "available", "in", "the", "current", "entry", "point" ]
train
https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/system_methods.py#L7-L12
alorence/django-modern-rpc
modernrpc/system_methods.py
__system_methodSignature
def __system_methodSignature(method_name, **kwargs): """ Returns an array describing the signature of the given method name. The result is an array with: - Return type as first elements - Types of method arguments from element 1 to N :param method_name: Name of a method available for current ...
python
def __system_methodSignature(method_name, **kwargs): """ Returns an array describing the signature of the given method name. The result is an array with: - Return type as first elements - Types of method arguments from element 1 to N :param method_name: Name of a method available for current ...
[ "def", "__system_methodSignature", "(", "method_name", ",", "*", "*", "kwargs", ")", ":", "entry_point", "=", "kwargs", ".", "get", "(", "ENTRY_POINT_KEY", ")", "protocol", "=", "kwargs", ".", "get", "(", "PROTOCOL_KEY", ")", "method", "=", "registry", ".", ...
Returns an array describing the signature of the given method name. The result is an array with: - Return type as first elements - Types of method arguments from element 1 to N :param method_name: Name of a method available for current entry point (and protocol) :param kwargs: :return: An arr...
[ "Returns", "an", "array", "describing", "the", "signature", "of", "the", "given", "method", "name", "." ]
train
https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/system_methods.py#L16-L33
alorence/django-modern-rpc
modernrpc/system_methods.py
__system_methodHelp
def __system_methodHelp(method_name, **kwargs): """ Returns the documentation of the given method name. :param method_name: Name of a method available for current entry point (and protocol) :param kwargs: :return: Documentation text for the RPC method """ entry_point = kwargs.get(ENTRY_POIN...
python
def __system_methodHelp(method_name, **kwargs): """ Returns the documentation of the given method name. :param method_name: Name of a method available for current entry point (and protocol) :param kwargs: :return: Documentation text for the RPC method """ entry_point = kwargs.get(ENTRY_POIN...
[ "def", "__system_methodHelp", "(", "method_name", ",", "*", "*", "kwargs", ")", ":", "entry_point", "=", "kwargs", ".", "get", "(", "ENTRY_POINT_KEY", ")", "protocol", "=", "kwargs", ".", "get", "(", "PROTOCOL_KEY", ")", "method", "=", "registry", ".", "ge...
Returns the documentation of the given method name. :param method_name: Name of a method available for current entry point (and protocol) :param kwargs: :return: Documentation text for the RPC method
[ "Returns", "the", "documentation", "of", "the", "given", "method", "name", "." ]
train
https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/system_methods.py#L37-L51
alorence/django-modern-rpc
modernrpc/system_methods.py
__system_multiCall
def __system_multiCall(calls, **kwargs): """ Call multiple RPC methods at once. :param calls: An array of struct like {"methodName": string, "params": array } :param kwargs: Internal data :type calls: list :type kwargs: dict :return: """ if not isinstance(calls, list): raise...
python
def __system_multiCall(calls, **kwargs): """ Call multiple RPC methods at once. :param calls: An array of struct like {"methodName": string, "params": array } :param kwargs: Internal data :type calls: list :type kwargs: dict :return: """ if not isinstance(calls, list): raise...
[ "def", "__system_multiCall", "(", "calls", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "calls", ",", "list", ")", ":", "raise", "RPCInvalidParams", "(", "'system.multicall first argument should be a list, {} given.'", ".", "format", "(", "ty...
Call multiple RPC methods at once. :param calls: An array of struct like {"methodName": string, "params": array } :param kwargs: Internal data :type calls: list :type kwargs: dict :return:
[ "Call", "multiple", "RPC", "methods", "at", "once", "." ]
train
https://github.com/alorence/django-modern-rpc/blob/6dc42857d35764b24e2c09334f4b578629a75f9e/modernrpc/system_methods.py#L55-L92
dcoker/awsmfa
awsmfa/__main__.py
acquire_code
def acquire_code(args, session, session3): """returns the user's token serial number, MFA token code, and an error code.""" serial_number = find_mfa_for_user(args.serial_number, session, session3) if not serial_number: print("There are no MFA devices associated with this user.", fi...
python
def acquire_code(args, session, session3): """returns the user's token serial number, MFA token code, and an error code.""" serial_number = find_mfa_for_user(args.serial_number, session, session3) if not serial_number: print("There are no MFA devices associated with this user.", fi...
[ "def", "acquire_code", "(", "args", ",", "session", ",", "session3", ")", ":", "serial_number", "=", "find_mfa_for_user", "(", "args", ".", "serial_number", ",", "session", ",", "session3", ")", "if", "not", "serial_number", ":", "print", "(", "\"There are no ...
returns the user's token serial number, MFA token code, and an error code.
[ "returns", "the", "user", "s", "token", "serial", "number", "MFA", "token", "code", "and", "an", "error", "code", "." ]
train
https://github.com/dcoker/awsmfa/blob/18a8216bfd3184c78b4067edf5198250f66e003d/awsmfa/__main__.py#L157-L170
dcoker/awsmfa
awsmfa/__main__.py
rotate
def rotate(args, credentials): """rotate the identity profile's AWS access key pair.""" current_access_key_id = credentials.get( args.identity_profile, 'aws_access_key_id') # create new sessions using the MFA credentials session, session3, err = make_session(args.target_profile) if err: ...
python
def rotate(args, credentials): """rotate the identity profile's AWS access key pair.""" current_access_key_id = credentials.get( args.identity_profile, 'aws_access_key_id') # create new sessions using the MFA credentials session, session3, err = make_session(args.target_profile) if err: ...
[ "def", "rotate", "(", "args", ",", "credentials", ")", ":", "current_access_key_id", "=", "credentials", ".", "get", "(", "args", ".", "identity_profile", ",", "'aws_access_key_id'", ")", "# create new sessions using the MFA credentials", "session", ",", "session3", "...
rotate the identity profile's AWS access key pair.
[ "rotate", "the", "identity", "profile", "s", "AWS", "access", "key", "pair", "." ]
train
https://github.com/dcoker/awsmfa/blob/18a8216bfd3184c78b4067edf5198250f66e003d/awsmfa/__main__.py#L180-L211
matiasb/demiurge
demiurge/demiurge.py
BaseField.coerce
def coerce(self, value): """Coerce a cleaned value.""" if self._coerce is not None: value = self._coerce(value) return value
python
def coerce(self, value): """Coerce a cleaned value.""" if self._coerce is not None: value = self._coerce(value) return value
[ "def", "coerce", "(", "self", ",", "value", ")", ":", "if", "self", ".", "_coerce", "is", "not", "None", ":", "value", "=", "self", ".", "_coerce", "(", "value", ")", "return", "value" ]
Coerce a cleaned value.
[ "Coerce", "a", "cleaned", "value", "." ]
train
https://github.com/matiasb/demiurge/blob/4cfbb24f0519ab99b9bf36fa4c20283ae6e7b9fe/demiurge/demiurge.py#L37-L41
matiasb/demiurge
demiurge/demiurge.py
Item.all_from
def all_from(cls, *args, **kwargs): """Query for items passing PyQuery args explicitly.""" pq_items = cls._get_items(*args, **kwargs) return [cls(item=i) for i in pq_items.items()]
python
def all_from(cls, *args, **kwargs): """Query for items passing PyQuery args explicitly.""" pq_items = cls._get_items(*args, **kwargs) return [cls(item=i) for i in pq_items.items()]
[ "def", "all_from", "(", "cls", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "pq_items", "=", "cls", ".", "_get_items", "(", "*", "args", ",", "*", "*", "kwargs", ")", "return", "[", "cls", "(", "item", "=", "i", ")", "for", "i", "in", ...
Query for items passing PyQuery args explicitly.
[ "Query", "for", "items", "passing", "PyQuery", "args", "explicitly", "." ]
train
https://github.com/matiasb/demiurge/blob/4cfbb24f0519ab99b9bf36fa4c20283ae6e7b9fe/demiurge/demiurge.py#L234-L237
matiasb/demiurge
demiurge/demiurge.py
Item.one
def one(cls, path='', index=0): """Return ocurrence (the first one, unless specified) of the item.""" url = urljoin(cls._meta.base_url, path) pq_items = cls._get_items(url=url, **cls._meta._pyquery_kwargs) item = pq_items.eq(index) if not item: raise ItemDoesNotExist(...
python
def one(cls, path='', index=0): """Return ocurrence (the first one, unless specified) of the item.""" url = urljoin(cls._meta.base_url, path) pq_items = cls._get_items(url=url, **cls._meta._pyquery_kwargs) item = pq_items.eq(index) if not item: raise ItemDoesNotExist(...
[ "def", "one", "(", "cls", ",", "path", "=", "''", ",", "index", "=", "0", ")", ":", "url", "=", "urljoin", "(", "cls", ".", "_meta", ".", "base_url", ",", "path", ")", "pq_items", "=", "cls", ".", "_get_items", "(", "url", "=", "url", ",", "*",...
Return ocurrence (the first one, unless specified) of the item.
[ "Return", "ocurrence", "(", "the", "first", "one", "unless", "specified", ")", "of", "the", "item", "." ]
train
https://github.com/matiasb/demiurge/blob/4cfbb24f0519ab99b9bf36fa4c20283ae6e7b9fe/demiurge/demiurge.py#L240-L247
matiasb/demiurge
demiurge/demiurge.py
Item.all
def all(cls, path=''): """Return all ocurrences of the item.""" url = urljoin(cls._meta.base_url, path) pq_items = cls._get_items(url=url, **cls._meta._pyquery_kwargs) return [cls(item=i) for i in pq_items.items()]
python
def all(cls, path=''): """Return all ocurrences of the item.""" url = urljoin(cls._meta.base_url, path) pq_items = cls._get_items(url=url, **cls._meta._pyquery_kwargs) return [cls(item=i) for i in pq_items.items()]
[ "def", "all", "(", "cls", ",", "path", "=", "''", ")", ":", "url", "=", "urljoin", "(", "cls", ".", "_meta", ".", "base_url", ",", "path", ")", "pq_items", "=", "cls", ".", "_get_items", "(", "url", "=", "url", ",", "*", "*", "cls", ".", "_meta...
Return all ocurrences of the item.
[ "Return", "all", "ocurrences", "of", "the", "item", "." ]
train
https://github.com/matiasb/demiurge/blob/4cfbb24f0519ab99b9bf36fa4c20283ae6e7b9fe/demiurge/demiurge.py#L250-L254
fulfilio/python-magento
magento/customer.py
Customer.info
def info(self, id, attributes=None): """ Retrieve customer data :param id: ID of customer :param attributes: `List` of attributes needed """ if attributes: return self.call('customer.info', [id, attributes]) else: return self.call('custome...
python
def info(self, id, attributes=None): """ Retrieve customer data :param id: ID of customer :param attributes: `List` of attributes needed """ if attributes: return self.call('customer.info', [id, attributes]) else: return self.call('custome...
[ "def", "info", "(", "self", ",", "id", ",", "attributes", "=", "None", ")", ":", "if", "attributes", ":", "return", "self", ".", "call", "(", "'customer.info'", ",", "[", "id", ",", "attributes", "]", ")", "else", ":", "return", "self", ".", "call", ...
Retrieve customer data :param id: ID of customer :param attributes: `List` of attributes needed
[ "Retrieve", "customer", "data" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/customer.py#L48-L58
fulfilio/python-magento
magento/sales.py
Order.search
def search(self, filters=None, fields=None, limit=None, page=1): """ Retrieve order list by options using search api. Using this result can be paginated :param options: Dictionary of options. :param filters: `{<attribute>:{<operator>:<value>}}` :param fields: [<String: ...
python
def search(self, filters=None, fields=None, limit=None, page=1): """ Retrieve order list by options using search api. Using this result can be paginated :param options: Dictionary of options. :param filters: `{<attribute>:{<operator>:<value>}}` :param fields: [<String: ...
[ "def", "search", "(", "self", ",", "filters", "=", "None", ",", "fields", "=", "None", ",", "limit", "=", "None", ",", "page", "=", "1", ")", ":", "options", "=", "{", "'imported'", ":", "False", ",", "'filters'", ":", "filters", "or", "{", "}", ...
Retrieve order list by options using search api. Using this result can be paginated :param options: Dictionary of options. :param filters: `{<attribute>:{<operator>:<value>}}` :param fields: [<String: magento field names>, ...] :param limit: `page limit` :param page: `c...
[ "Retrieve", "order", "list", "by", "options", "using", "search", "api", ".", "Using", "this", "result", "can", "be", "paginated" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/sales.py#L34-L55
fulfilio/python-magento
magento/sales.py
Order.addcomment
def addcomment(self, order_increment_id, status, comment=None, notify=False): """ Add comment to order or change its state :param order_increment_id: Order ID TODO: Identify possible values for status """ if comment is None: comment = "" r...
python
def addcomment(self, order_increment_id, status, comment=None, notify=False): """ Add comment to order or change its state :param order_increment_id: Order ID TODO: Identify possible values for status """ if comment is None: comment = "" r...
[ "def", "addcomment", "(", "self", ",", "order_increment_id", ",", "status", ",", "comment", "=", "None", ",", "notify", "=", "False", ")", ":", "if", "comment", "is", "None", ":", "comment", "=", "\"\"", "return", "bool", "(", "self", ".", "call", "(",...
Add comment to order or change its state :param order_increment_id: Order ID TODO: Identify possible values for status
[ "Add", "comment", "to", "order", "or", "change", "its", "state" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/sales.py#L78-L92
fulfilio/python-magento
magento/sales.py
CreditMemo.create
def create( self, order_increment_id, creditmemo_data=None, comment=None, email=False, include_comment=False, refund_to_store_credit_amount=None): """ Create new credit_memo for order :param order_increment_id: ...
python
def create( self, order_increment_id, creditmemo_data=None, comment=None, email=False, include_comment=False, refund_to_store_credit_amount=None): """ Create new credit_memo for order :param order_increment_id: ...
[ "def", "create", "(", "self", ",", "order_increment_id", ",", "creditmemo_data", "=", "None", ",", "comment", "=", "None", ",", "email", "=", "False", ",", "include_comment", "=", "False", ",", "refund_to_store_credit_amount", "=", "None", ")", ":", "if", "c...
Create new credit_memo for order :param order_increment_id: Order Increment ID :type order_increment_id: str :param creditmemo_data: Sales order credit memo data (optional) :type creditmemo_data: associative array as dict { 'qtys': [ { ...
[ "Create", "new", "credit_memo", "for", "order" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/sales.py#L153-L199
fulfilio/python-magento
magento/sales.py
CreditMemo.addcomment
def addcomment(self, creditmemo_increment_id, comment, email=True, include_in_email=False): """ Add new comment to credit memo :param creditmemo_increment_id: Credit memo increment ID :return: bool """ return bool( self.call( 'sal...
python
def addcomment(self, creditmemo_increment_id, comment, email=True, include_in_email=False): """ Add new comment to credit memo :param creditmemo_increment_id: Credit memo increment ID :return: bool """ return bool( self.call( 'sal...
[ "def", "addcomment", "(", "self", ",", "creditmemo_increment_id", ",", "comment", ",", "email", "=", "True", ",", "include_in_email", "=", "False", ")", ":", "return", "bool", "(", "self", ".", "call", "(", "'sales_order_creditmemo.addComment'", ",", "[", "cre...
Add new comment to credit memo :param creditmemo_increment_id: Credit memo increment ID :return: bool
[ "Add", "new", "comment", "to", "credit", "memo" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/sales.py#L201-L215
fulfilio/python-magento
magento/sales.py
Shipment.create
def create(self, order_increment_id, items_qty, comment=None, email=True, include_comment=False): """ Create new shipment for order :param order_increment_id: Order Increment ID :type order_increment_id: str :param items_qty: items qty to ship :type items_qty...
python
def create(self, order_increment_id, items_qty, comment=None, email=True, include_comment=False): """ Create new shipment for order :param order_increment_id: Order Increment ID :type order_increment_id: str :param items_qty: items qty to ship :type items_qty...
[ "def", "create", "(", "self", ",", "order_increment_id", ",", "items_qty", ",", "comment", "=", "None", ",", "email", "=", "True", ",", "include_comment", "=", "False", ")", ":", "if", "comment", "is", "None", ":", "comment", "=", "''", "return", "self",...
Create new shipment for order :param order_increment_id: Order Increment ID :type order_increment_id: str :param items_qty: items qty to ship :type items_qty: associative array (order_item_id ⇒ qty) as dict :param comment: Shipment Comment :type comment: str :par...
[ "Create", "new", "shipment", "for", "order" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/sales.py#L262-L284
fulfilio/python-magento
magento/sales.py
Shipment.addtrack
def addtrack(self, shipment_increment_id, carrier, title, track_number): """ Add new tracking number :param shipment_increment_id: Shipment ID :param carrier: Carrier Code :param title: Tracking title :param track_number: Tracking Number """ return self.c...
python
def addtrack(self, shipment_increment_id, carrier, title, track_number): """ Add new tracking number :param shipment_increment_id: Shipment ID :param carrier: Carrier Code :param title: Tracking title :param track_number: Tracking Number """ return self.c...
[ "def", "addtrack", "(", "self", ",", "shipment_increment_id", ",", "carrier", ",", "title", ",", "track_number", ")", ":", "return", "self", ".", "call", "(", "'sales_order_shipment.addTrack'", ",", "[", "shipment_increment_id", ",", "carrier", ",", "title", ","...
Add new tracking number :param shipment_increment_id: Shipment ID :param carrier: Carrier Code :param title: Tracking title :param track_number: Tracking Number
[ "Add", "new", "tracking", "number" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/sales.py#L303-L315
fulfilio/python-magento
magento/sales.py
Invoice.addcomment
def addcomment(self, invoice_increment_id, comment=None, email=False, include_comment=False): """ Add comment to invoice or change its state :param invoice_increment_id: Invoice ID """ if comment is None: comment = "" return bool( self...
python
def addcomment(self, invoice_increment_id, comment=None, email=False, include_comment=False): """ Add comment to invoice or change its state :param invoice_increment_id: Invoice ID """ if comment is None: comment = "" return bool( self...
[ "def", "addcomment", "(", "self", ",", "invoice_increment_id", ",", "comment", "=", "None", ",", "email", "=", "False", ",", "include_comment", "=", "False", ")", ":", "if", "comment", "is", "None", ":", "comment", "=", "\"\"", "return", "bool", "(", "se...
Add comment to invoice or change its state :param invoice_increment_id: Invoice ID
[ "Add", "comment", "to", "invoice", "or", "change", "its", "state" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/sales.py#L418-L432
fulfilio/python-magento
magento/utils.py
expand_url
def expand_url(url, protocol): """ Expands the given URL to a full URL by adding the magento soap/wsdl parts :param url: URL to be expanded :param service: 'xmlrpc' or 'soap' """ if protocol == 'soap': ws_part = 'api/?wsdl' elif protocol == 'xmlrpc': ws_part = 'index.php...
python
def expand_url(url, protocol): """ Expands the given URL to a full URL by adding the magento soap/wsdl parts :param url: URL to be expanded :param service: 'xmlrpc' or 'soap' """ if protocol == 'soap': ws_part = 'api/?wsdl' elif protocol == 'xmlrpc': ws_part = 'index.php...
[ "def", "expand_url", "(", "url", ",", "protocol", ")", ":", "if", "protocol", "==", "'soap'", ":", "ws_part", "=", "'api/?wsdl'", "elif", "protocol", "==", "'xmlrpc'", ":", "ws_part", "=", "'index.php/api/xmlrpc'", "else", ":", "ws_part", "=", "'index.php/rest...
Expands the given URL to a full URL by adding the magento soap/wsdl parts :param url: URL to be expanded :param service: 'xmlrpc' or 'soap'
[ "Expands", "the", "given", "URL", "to", "a", "full", "URL", "by", "adding", "the", "magento", "soap", "/", "wsdl", "parts" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/utils.py#L12-L26
fulfilio/python-magento
magento/utils.py
camel_2_snake
def camel_2_snake(name): "Converts CamelCase to camel_case" s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
python
def camel_2_snake(name): "Converts CamelCase to camel_case" s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower()
[ "def", "camel_2_snake", "(", "name", ")", ":", "s1", "=", "re", ".", "sub", "(", "'(.)([A-Z][a-z]+)'", ",", "r'\\1_\\2'", ",", "name", ")", "return", "re", ".", "sub", "(", "'([a-z0-9])([A-Z])'", ",", "r'\\1_\\2'", ",", "s1", ")", ".", "lower", "(", ")...
Converts CamelCase to camel_case
[ "Converts", "CamelCase", "to", "camel_case" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/utils.py#L29-L32
fulfilio/python-magento
magento/catalog.py
Category.level
def level(self, website=None, store_view=None, parent_category=None): """ Retrieve one level of categories by website/store view/parent category :param website: Website code or ID :param store_view: storeview code or ID :param parent_category: Parent Category ID :return:...
python
def level(self, website=None, store_view=None, parent_category=None): """ Retrieve one level of categories by website/store view/parent category :param website: Website code or ID :param store_view: storeview code or ID :param parent_category: Parent Category ID :return:...
[ "def", "level", "(", "self", ",", "website", "=", "None", ",", "store_view", "=", "None", ",", "parent_category", "=", "None", ")", ":", "return", "self", ".", "call", "(", "'catalog_category.level'", ",", "[", "website", ",", "store_view", ",", "parent_ca...
Retrieve one level of categories by website/store view/parent category :param website: Website code or ID :param store_view: storeview code or ID :param parent_category: Parent Category ID :return: Dictionary
[ "Retrieve", "one", "level", "of", "categories", "by", "website", "/", "store", "view", "/", "parent", "category" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L41-L52
fulfilio/python-magento
magento/catalog.py
Category.info
def info(self, category_id, store_view=None, attributes=None): """ Retrieve Category details :param category_id: ID of category to retrieve :param store_view: Store view ID or code :param attributes: Return the fields specified :return: Dictionary of data """ ...
python
def info(self, category_id, store_view=None, attributes=None): """ Retrieve Category details :param category_id: ID of category to retrieve :param store_view: Store view ID or code :param attributes: Return the fields specified :return: Dictionary of data """ ...
[ "def", "info", "(", "self", ",", "category_id", ",", "store_view", "=", "None", ",", "attributes", "=", "None", ")", ":", "return", "self", ".", "call", "(", "'catalog_category.info'", ",", "[", "category_id", ",", "store_view", ",", "attributes", "]", ")"...
Retrieve Category details :param category_id: ID of category to retrieve :param store_view: Store view ID or code :param attributes: Return the fields specified :return: Dictionary of data
[ "Retrieve", "Category", "details" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L54-L65
fulfilio/python-magento
magento/catalog.py
Category.create
def create(self, parent_id, data, store_view=None): """ Create new category and return its ID :param parent_id: ID of parent :param data: Data for category :param store_view: Store view ID or Code :return: Integer ID """ return int(self.call( ...
python
def create(self, parent_id, data, store_view=None): """ Create new category and return its ID :param parent_id: ID of parent :param data: Data for category :param store_view: Store view ID or Code :return: Integer ID """ return int(self.call( ...
[ "def", "create", "(", "self", ",", "parent_id", ",", "data", ",", "store_view", "=", "None", ")", ":", "return", "int", "(", "self", ".", "call", "(", "'catalog_category.create'", ",", "[", "parent_id", ",", "data", ",", "store_view", "]", ")", ")" ]
Create new category and return its ID :param parent_id: ID of parent :param data: Data for category :param store_view: Store view ID or Code :return: Integer ID
[ "Create", "new", "category", "and", "return", "its", "ID" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L67-L78
fulfilio/python-magento
magento/catalog.py
Category.update
def update(self, category_id, data, store_view=None): """ Update Category :param category_id: ID of category :param data: Category Data :param store_view: Store view ID or code :return: Boolean """ return bool( self.call( 'cata...
python
def update(self, category_id, data, store_view=None): """ Update Category :param category_id: ID of category :param data: Category Data :param store_view: Store view ID or code :return: Boolean """ return bool( self.call( 'cata...
[ "def", "update", "(", "self", ",", "category_id", ",", "data", ",", "store_view", "=", "None", ")", ":", "return", "bool", "(", "self", ".", "call", "(", "'catalog_category.update'", ",", "[", "category_id", ",", "data", ",", "store_view", "]", ")", ")" ...
Update Category :param category_id: ID of category :param data: Category Data :param store_view: Store view ID or code :return: Boolean
[ "Update", "Category" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L80-L93
fulfilio/python-magento
magento/catalog.py
Category.move
def move(self, category_id, parent_id, after_id=None): """ Move category in tree :param category_id: ID of category to move :param parent_id: New parent of the category :param after_id: Category ID after what position it will be moved :return: Boolean """ ...
python
def move(self, category_id, parent_id, after_id=None): """ Move category in tree :param category_id: ID of category to move :param parent_id: New parent of the category :param after_id: Category ID after what position it will be moved :return: Boolean """ ...
[ "def", "move", "(", "self", ",", "category_id", ",", "parent_id", ",", "after_id", "=", "None", ")", ":", "return", "bool", "(", "self", ".", "call", "(", "'catalog_category.move'", ",", "[", "category_id", ",", "parent_id", ",", "after_id", "]", ")", ")...
Move category in tree :param category_id: ID of category to move :param parent_id: New parent of the category :param after_id: Category ID after what position it will be moved :return: Boolean
[ "Move", "category", "in", "tree" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L95-L106
fulfilio/python-magento
magento/catalog.py
Category.assignproduct
def assignproduct(self, category_id, product, position=None): """ Assign product to a category :param category_id: ID of a category :param product: ID or Code of the product :param position: Position of product in category :return: boolean """ return boo...
python
def assignproduct(self, category_id, product, position=None): """ Assign product to a category :param category_id: ID of a category :param product: ID or Code of the product :param position: Position of product in category :return: boolean """ return boo...
[ "def", "assignproduct", "(", "self", ",", "category_id", ",", "product", ",", "position", "=", "None", ")", ":", "return", "bool", "(", "self", ".", "call", "(", "'catalog_category.assignProduct'", ",", "[", "category_id", ",", "product", ",", "position", "]...
Assign product to a category :param category_id: ID of a category :param product: ID or Code of the product :param position: Position of product in category :return: boolean
[ "Assign", "product", "to", "a", "category" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L133-L145
fulfilio/python-magento
magento/catalog.py
Category.updateproduct
def updateproduct(self, category_id, product, position=None): """ Update assigned product :param category_id: ID of a category :param product: ID or Code of the product :param position: Position of product in category :return: boolean """ return bool(sel...
python
def updateproduct(self, category_id, product, position=None): """ Update assigned product :param category_id: ID of a category :param product: ID or Code of the product :param position: Position of product in category :return: boolean """ return bool(sel...
[ "def", "updateproduct", "(", "self", ",", "category_id", ",", "product", ",", "position", "=", "None", ")", ":", "return", "bool", "(", "self", ".", "call", "(", "'catalog_category.updateProduct'", ",", "[", "category_id", ",", "product", ",", "position", "]...
Update assigned product :param category_id: ID of a category :param product: ID or Code of the product :param position: Position of product in category :return: boolean
[ "Update", "assigned", "product" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L150-L162
fulfilio/python-magento
magento/catalog.py
CategoryAttribute.currentStore
def currentStore(self, store_view=None): """ Set/Get current store view :param store_view: Store view ID or Code :return: int """ args = [store_view] if store_view else [] return int(self.call('catalog_category_attribute.currentStore', args))
python
def currentStore(self, store_view=None): """ Set/Get current store view :param store_view: Store view ID or Code :return: int """ args = [store_view] if store_view else [] return int(self.call('catalog_category_attribute.currentStore', args))
[ "def", "currentStore", "(", "self", ",", "store_view", "=", "None", ")", ":", "args", "=", "[", "store_view", "]", "if", "store_view", "else", "[", "]", "return", "int", "(", "self", ".", "call", "(", "'catalog_category_attribute.currentStore'", ",", "args",...
Set/Get current store view :param store_view: Store view ID or Code :return: int
[ "Set", "/", "Get", "current", "store", "view" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L191-L199
fulfilio/python-magento
magento/catalog.py
Product.info
def info(self, product, store_view=None, attributes=None, identifierType=None): """ Retrieve product data :param product: ID or SKU of product :param store_view: ID or Code of store view :param attributes: List of fields required :param identifierType: Defin...
python
def info(self, product, store_view=None, attributes=None, identifierType=None): """ Retrieve product data :param product: ID or SKU of product :param store_view: ID or Code of store view :param attributes: List of fields required :param identifierType: Defin...
[ "def", "info", "(", "self", ",", "product", ",", "store_view", "=", "None", ",", "attributes", "=", "None", ",", "identifierType", "=", "None", ")", ":", "return", "self", ".", "call", "(", "'catalog_product.info'", ",", "[", "product", ",", "store_view", ...
Retrieve product data :param product: ID or SKU of product :param store_view: ID or Code of store view :param attributes: List of fields required :param identifierType: Defines whether the product or SKU value is passed in the "product" parameter. ...
[ "Retrieve", "product", "data" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L253-L270
fulfilio/python-magento
magento/catalog.py
Product.create
def create(self, product_type, attribute_set_id, sku, data): """ Create Product and return ID :param product_type: String type of product :param attribute_set_id: ID of attribute set :param sku: SKU of the product :param data: Dictionary of data :return: INT id o...
python
def create(self, product_type, attribute_set_id, sku, data): """ Create Product and return ID :param product_type: String type of product :param attribute_set_id: ID of attribute set :param sku: SKU of the product :param data: Dictionary of data :return: INT id o...
[ "def", "create", "(", "self", ",", "product_type", ",", "attribute_set_id", ",", "sku", ",", "data", ")", ":", "return", "int", "(", "self", ".", "call", "(", "'catalog_product.create'", ",", "[", "product_type", ",", "attribute_set_id", ",", "sku", ",", "...
Create Product and return ID :param product_type: String type of product :param attribute_set_id: ID of attribute set :param sku: SKU of the product :param data: Dictionary of data :return: INT id of product created
[ "Create", "Product", "and", "return", "ID" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L272-L286
fulfilio/python-magento
magento/catalog.py
Product.update
def update(self, product, data, store_view=None, identifierType=None): """ Update product Information :param product: ID or SKU of product :param data: Dictionary of attributes to update :param store_view: ID or Code of store view :param identifierType: Defines whether t...
python
def update(self, product, data, store_view=None, identifierType=None): """ Update product Information :param product: ID or SKU of product :param data: Dictionary of attributes to update :param store_view: ID or Code of store view :param identifierType: Defines whether t...
[ "def", "update", "(", "self", ",", "product", ",", "data", ",", "store_view", "=", "None", ",", "identifierType", "=", "None", ")", ":", "return", "bool", "(", "self", ".", "call", "(", "'catalog_product.update'", ",", "[", "product", ",", "data", ",", ...
Update product Information :param product: ID or SKU of product :param data: Dictionary of attributes to update :param store_view: ID or Code of store view :param identifierType: Defines whether the product or SKU value is passed in the "product" parameter...
[ "Update", "product", "Information" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L288-L303
fulfilio/python-magento
magento/catalog.py
Product.setSpecialPrice
def setSpecialPrice(self, product, special_price=None, from_date=None, to_date=None, store_view=None, identifierType=None): """ Update product's special price :param product: ID or SKU of product :param special_price: Special Price ...
python
def setSpecialPrice(self, product, special_price=None, from_date=None, to_date=None, store_view=None, identifierType=None): """ Update product's special price :param product: ID or SKU of product :param special_price: Special Price ...
[ "def", "setSpecialPrice", "(", "self", ",", "product", ",", "special_price", "=", "None", ",", "from_date", "=", "None", ",", "to_date", "=", "None", ",", "store_view", "=", "None", ",", "identifierType", "=", "None", ")", ":", "return", "bool", "(", "se...
Update product's special price :param product: ID or SKU of product :param special_price: Special Price :param from_date: From date :param to_date: To Date :param store_view: ID or Code of Store View :param identifierType: Defines whether the product or SKU value is ...
[ "Update", "product", "s", "special", "price" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L305-L326
fulfilio/python-magento
magento/catalog.py
Product.getSpecialPrice
def getSpecialPrice(self, product, store_view=None, identifierType=None): """ Get product special price data :param product: ID or SKU of product :param store_view: ID or Code of Store view :param identifierType: Defines whether the product or SKU value is ...
python
def getSpecialPrice(self, product, store_view=None, identifierType=None): """ Get product special price data :param product: ID or SKU of product :param store_view: ID or Code of Store view :param identifierType: Defines whether the product or SKU value is ...
[ "def", "getSpecialPrice", "(", "self", ",", "product", ",", "store_view", "=", "None", ",", "identifierType", "=", "None", ")", ":", "return", "self", ".", "call", "(", "'catalog_product.getSpecialPrice'", ",", "[", "product", ",", "store_view", ",", "identifi...
Get product special price data :param product: ID or SKU of product :param store_view: ID or Code of Store view :param identifierType: Defines whether the product or SKU value is passed in the "product" parameter. :return: Dictionary
[ "Get", "product", "special", "price", "data" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L328-L343
fulfilio/python-magento
magento/catalog.py
ProductImages.list
def list(self, product, store_view=None, identifierType=None): """ Retrieve product image list :param product: ID or SKU of product :param store_view: Code or ID of store view :param identifierType: Defines whether the product or SKU value is passe...
python
def list(self, product, store_view=None, identifierType=None): """ Retrieve product image list :param product: ID or SKU of product :param store_view: Code or ID of store view :param identifierType: Defines whether the product or SKU value is passe...
[ "def", "list", "(", "self", ",", "product", ",", "store_view", "=", "None", ",", "identifierType", "=", "None", ")", ":", "return", "self", ".", "call", "(", "'catalog_product_attribute_media.list'", ",", "[", "product", ",", "store_view", ",", "identifierType...
Retrieve product image list :param product: ID or SKU of product :param store_view: Code or ID of store view :param identifierType: Defines whether the product or SKU value is passed in the "product" parameter. :return: `list` of `dict`
[ "Retrieve", "product", "image", "list" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L539-L551
fulfilio/python-magento
magento/catalog.py
ProductImages.info
def info(self, product, image_file, store_view=None, identifierType=None): """ Retrieve product image data :param product: ID or SKU of product :param store_view: ID or Code of store view :param attributes: List of fields required :param identifierType: Defines whether t...
python
def info(self, product, image_file, store_view=None, identifierType=None): """ Retrieve product image data :param product: ID or SKU of product :param store_view: ID or Code of store view :param attributes: List of fields required :param identifierType: Defines whether t...
[ "def", "info", "(", "self", ",", "product", ",", "image_file", ",", "store_view", "=", "None", ",", "identifierType", "=", "None", ")", ":", "return", "self", ".", "call", "(", "'catalog_product_attribute_media.info'", ",", "[", "product", ",", "image_file", ...
Retrieve product image data :param product: ID or SKU of product :param store_view: ID or Code of store view :param attributes: List of fields required :param identifierType: Defines whether the product or SKU value is passed in the "product" parameter. ...
[ "Retrieve", "product", "image", "data" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L553-L566
fulfilio/python-magento
magento/catalog.py
ProductImages.create
def create(self, product, data, store_view=None, identifierType=None): """ Upload a new product image. :param product: ID or SKU of product :param data: `dict` of image data (label, position, exclude, types) Example: { 'label': 'description of photo', 'positi...
python
def create(self, product, data, store_view=None, identifierType=None): """ Upload a new product image. :param product: ID or SKU of product :param data: `dict` of image data (label, position, exclude, types) Example: { 'label': 'description of photo', 'positi...
[ "def", "create", "(", "self", ",", "product", ",", "data", ",", "store_view", "=", "None", ",", "identifierType", "=", "None", ")", ":", "return", "self", ".", "call", "(", "'catalog_product_attribute_media.create'", ",", "[", "product", ",", "data", ",", ...
Upload a new product image. :param product: ID or SKU of product :param data: `dict` of image data (label, position, exclude, types) Example: { 'label': 'description of photo', 'position': '1', 'exclude': '0', 'types': ['image', 'small_image', 'thumbnail']} ...
[ "Upload", "a", "new", "product", "image", "." ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L578-L594
fulfilio/python-magento
magento/catalog.py
ProductImages.update
def update(self, product, img_file_name, data, store_view=None, identifierType=None): """ Update a product image. :param product: ID or SKU of product :param img_file_name: The image file name Example: '/m/y/my_image_thumb.jpg' :param data: `dict` of i...
python
def update(self, product, img_file_name, data, store_view=None, identifierType=None): """ Update a product image. :param product: ID or SKU of product :param img_file_name: The image file name Example: '/m/y/my_image_thumb.jpg' :param data: `dict` of i...
[ "def", "update", "(", "self", ",", "product", ",", "img_file_name", ",", "data", ",", "store_view", "=", "None", ",", "identifierType", "=", "None", ")", ":", "return", "self", ".", "call", "(", "'catalog_product_attribute_media.update'", ",", "[", "product", ...
Update a product image. :param product: ID or SKU of product :param img_file_name: The image file name Example: '/m/y/my_image_thumb.jpg' :param data: `dict` of image data (label, position, exclude, types) Example: { 'label': 'description of photo', 'posi...
[ "Update", "a", "product", "image", "." ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L596-L615
fulfilio/python-magento
magento/catalog.py
ProductImages.remove
def remove(self, product, img_file_name, identifierType=None): """ Remove a product image. :param product: ID or SKU of product :param img_file_name: The image file name Example: '/m/y/my_image_thumb.jpg' :param identifierType: Defines whether the product or SKU valu...
python
def remove(self, product, img_file_name, identifierType=None): """ Remove a product image. :param product: ID or SKU of product :param img_file_name: The image file name Example: '/m/y/my_image_thumb.jpg' :param identifierType: Defines whether the product or SKU valu...
[ "def", "remove", "(", "self", ",", "product", ",", "img_file_name", ",", "identifierType", "=", "None", ")", ":", "return", "self", ".", "call", "(", "'catalog_product_attribute_media.remove'", ",", "[", "product", ",", "img_file_name", ",", "identifierType", "]...
Remove a product image. :param product: ID or SKU of product :param img_file_name: The image file name Example: '/m/y/my_image_thumb.jpg' :param identifierType: Defines whether the product or SKU value is passed in the "product" parameter. :re...
[ "Remove", "a", "product", "image", "." ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L617-L630
fulfilio/python-magento
magento/catalog.py
ProductLinks.list
def list(self, link_type, product, identifierType=None): """ Retrieve list of linked products :param link_type: type of link, one of 'cross_sell', 'up_sell', 'related' or 'grouped' :param product: ID or SKU of product :param identifierType: Defines whether the pr...
python
def list(self, link_type, product, identifierType=None): """ Retrieve list of linked products :param link_type: type of link, one of 'cross_sell', 'up_sell', 'related' or 'grouped' :param product: ID or SKU of product :param identifierType: Defines whether the pr...
[ "def", "list", "(", "self", ",", "link_type", ",", "product", ",", "identifierType", "=", "None", ")", ":", "return", "self", ".", "call", "(", "'catalog_product_link.list'", ",", "[", "link_type", ",", "product", ",", "identifierType", "]", ")" ]
Retrieve list of linked products :param link_type: type of link, one of 'cross_sell', 'up_sell', 'related' or 'grouped' :param product: ID or SKU of product :param identifierType: Defines whether the product or SKU value is passed in the "product" ...
[ "Retrieve", "list", "of", "linked", "products" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L687-L700
fulfilio/python-magento
magento/catalog.py
ProductLinks.assign
def assign(self, link_type, product, linked_product, data=None, identifierType=None): """ Assign a product link :param link_type: type of link, one of 'cross_sell', 'up_sell', 'related' or 'grouped' :param product: ID or SKU of product :param linke...
python
def assign(self, link_type, product, linked_product, data=None, identifierType=None): """ Assign a product link :param link_type: type of link, one of 'cross_sell', 'up_sell', 'related' or 'grouped' :param product: ID or SKU of product :param linke...
[ "def", "assign", "(", "self", ",", "link_type", ",", "product", ",", "linked_product", ",", "data", "=", "None", ",", "identifierType", "=", "None", ")", ":", "return", "bool", "(", "self", ".", "call", "(", "'catalog_product_link.assign'", ",", "[", "link...
Assign a product link :param link_type: type of link, one of 'cross_sell', 'up_sell', 'related' or 'grouped' :param product: ID or SKU of product :param linked_product: ID or SKU of linked product :param data: dictionary of link data, (position, qty, etc.) ...
[ "Assign", "a", "product", "link" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L702-L719
fulfilio/python-magento
magento/catalog.py
ProductLinks.remove
def remove(self, link_type, product, linked_product, identifierType=None): """ Remove a product link :param link_type: type of link, one of 'cross_sell', 'up_sell', 'related' or 'grouped' :param product: ID or SKU of product :param linked_product: ID or SKU of li...
python
def remove(self, link_type, product, linked_product, identifierType=None): """ Remove a product link :param link_type: type of link, one of 'cross_sell', 'up_sell', 'related' or 'grouped' :param product: ID or SKU of product :param linked_product: ID or SKU of li...
[ "def", "remove", "(", "self", ",", "link_type", ",", "product", ",", "linked_product", ",", "identifierType", "=", "None", ")", ":", "return", "bool", "(", "self", ".", "call", "(", "'catalog_product_link.remove'", ",", "[", "link_type", ",", "product", ",",...
Remove a product link :param link_type: type of link, one of 'cross_sell', 'up_sell', 'related' or 'grouped' :param product: ID or SKU of product :param linked_product: ID or SKU of linked product to unlink :param identifierType: Defines whether the product or SKU value ...
[ "Remove", "a", "product", "link" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L740-L754
fulfilio/python-magento
magento/catalog.py
ProductConfigurable.update
def update(self, product, linked_products, attributes): """ Configurable Update product :param product: ID or SKU of product :param linked_products: List ID or SKU of linked product to link :param attributes: dicc :return: True/False """ return bool(self....
python
def update(self, product, linked_products, attributes): """ Configurable Update product :param product: ID or SKU of product :param linked_products: List ID or SKU of linked product to link :param attributes: dicc :return: True/False """ return bool(self....
[ "def", "update", "(", "self", ",", "product", ",", "linked_products", ",", "attributes", ")", ":", "return", "bool", "(", "self", ".", "call", "(", "'ol_catalog_product_link.assign'", ",", "[", "product", ",", "linked_products", ",", "attributes", "]", ")", ...
Configurable Update product :param product: ID or SKU of product :param linked_products: List ID or SKU of linked product to link :param attributes: dicc :return: True/False
[ "Configurable", "Update", "product" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/catalog.py#L819-L829
fulfilio/python-magento
magento/checkout.py
Cart.order
def order(self, quote_id, store_view=None, license_id=None): """ Allows you to create an order from a shopping cart (quote). Before placing the order, you need to add the customer, customer address, shipping and payment methods. :param quote_id: Shopping cart ID (quote ID) ...
python
def order(self, quote_id, store_view=None, license_id=None): """ Allows you to create an order from a shopping cart (quote). Before placing the order, you need to add the customer, customer address, shipping and payment methods. :param quote_id: Shopping cart ID (quote ID) ...
[ "def", "order", "(", "self", ",", "quote_id", ",", "store_view", "=", "None", ",", "license_id", "=", "None", ")", ":", "return", "self", ".", "call", "(", "'cart.order'", ",", "[", "quote_id", ",", "store_view", ",", "license_id", "]", ")" ]
Allows you to create an order from a shopping cart (quote). Before placing the order, you need to add the customer, customer address, shipping and payment methods. :param quote_id: Shopping cart ID (quote ID) :param store_view: Store view ID or code :param license_id: Website li...
[ "Allows", "you", "to", "create", "an", "order", "from", "a", "shopping", "cart", "(", "quote", ")", ".", "Before", "placing", "the", "order", "you", "need", "to", "add", "the", "customer", "customer", "address", "shipping", "and", "payment", "methods", "."...
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/checkout.py#L51-L62
fulfilio/python-magento
magento/checkout.py
CartCoupon.add
def add(self, quote_id, coupon_code, store_view=None): """ Add a coupon code to a quote. :param quote_id: Shopping cart ID (quote ID) :param coupon_code, string, Coupon code :param store_view: Store view ID or code :return: boolean, True if the coupon code is added ...
python
def add(self, quote_id, coupon_code, store_view=None): """ Add a coupon code to a quote. :param quote_id: Shopping cart ID (quote ID) :param coupon_code, string, Coupon code :param store_view: Store view ID or code :return: boolean, True if the coupon code is added ...
[ "def", "add", "(", "self", ",", "quote_id", ",", "coupon_code", ",", "store_view", "=", "None", ")", ":", "return", "bool", "(", "self", ".", "call", "(", "'cart_coupon.add'", ",", "[", "quote_id", ",", "coupon_code", ",", "store_view", "]", ")", ")" ]
Add a coupon code to a quote. :param quote_id: Shopping cart ID (quote ID) :param coupon_code, string, Coupon code :param store_view: Store view ID or code :return: boolean, True if the coupon code is added
[ "Add", "a", "coupon", "code", "to", "a", "quote", "." ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/checkout.py#L81-L92
fulfilio/python-magento
magento/checkout.py
CartCustomer.addresses
def addresses(self, quote_id, address_data, store_view=None): """ Add customer information into a shopping cart :param quote_id: Shopping cart ID (quote ID) :param address_data, list of dicts of address details, example [ { 'mode': 'billin...
python
def addresses(self, quote_id, address_data, store_view=None): """ Add customer information into a shopping cart :param quote_id: Shopping cart ID (quote ID) :param address_data, list of dicts of address details, example [ { 'mode': 'billin...
[ "def", "addresses", "(", "self", ",", "quote_id", ",", "address_data", ",", "store_view", "=", "None", ")", ":", "return", "bool", "(", "self", ".", "call", "(", "'cart_customer.addresses'", ",", "[", "quote_id", ",", "address_data", ",", "store_view", "]", ...
Add customer information into a shopping cart :param quote_id: Shopping cart ID (quote ID) :param address_data, list of dicts of address details, example [ { 'mode': 'billing', 'address_id': 'customer_address_id' }, ...
[ "Add", "customer", "information", "into", "a", "shopping", "cart" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/checkout.py#L113-L147
fulfilio/python-magento
magento/checkout.py
CartCustomer.set
def set(self, quote_id, customer_data, store_view=None): """ Add customer information into a shopping cart :param quote_id: Shopping cart ID (quote ID) :param customer_data, dict of customer details, example { 'firstname': 'testFirstname', 'la...
python
def set(self, quote_id, customer_data, store_view=None): """ Add customer information into a shopping cart :param quote_id: Shopping cart ID (quote ID) :param customer_data, dict of customer details, example { 'firstname': 'testFirstname', 'la...
[ "def", "set", "(", "self", ",", "quote_id", ",", "customer_data", ",", "store_view", "=", "None", ")", ":", "return", "bool", "(", "self", ".", "call", "(", "'cart_customer.set'", ",", "[", "quote_id", ",", "customer_data", ",", "store_view", "]", ")", "...
Add customer information into a shopping cart :param quote_id: Shopping cart ID (quote ID) :param customer_data, dict of customer details, example { 'firstname': 'testFirstname', 'lastname': 'testLastName', 'email': 'testEmail', ...
[ "Add", "customer", "information", "into", "a", "shopping", "cart" ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/checkout.py#L149-L169
fulfilio/python-magento
magento/checkout.py
CartPayment.method
def method(self, quote_id, payment_data, store_view=None): """ Allows you to set a payment method for a shopping cart (quote). :param quote_id: Shopping cart ID (quote ID) :param payment_data, dict of payment details, example { 'po_number': '', ...
python
def method(self, quote_id, payment_data, store_view=None): """ Allows you to set a payment method for a shopping cart (quote). :param quote_id: Shopping cart ID (quote ID) :param payment_data, dict of payment details, example { 'po_number': '', ...
[ "def", "method", "(", "self", ",", "quote_id", ",", "payment_data", ",", "store_view", "=", "None", ")", ":", "return", "bool", "(", "self", ".", "call", "(", "'cart_payment.method'", ",", "[", "quote_id", ",", "payment_data", ",", "store_view", "]", ")", ...
Allows you to set a payment method for a shopping cart (quote). :param quote_id: Shopping cart ID (quote ID) :param payment_data, dict of payment details, example { 'po_number': '', 'method': 'checkmo', 'cc_cid': '', 'cc_owner'...
[ "Allows", "you", "to", "set", "a", "payment", "method", "for", "a", "shopping", "cart", "(", "quote", ")", "." ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/checkout.py#L194-L216
fulfilio/python-magento
magento/checkout.py
CartProduct.add
def add(self, quote_id, product_data, store_view=None): """ Allows you to add one or more products to the shopping cart (quote). :param quote_id: Shopping cart ID (quote ID) :param product_data, list of dicts of product details, example [ { ...
python
def add(self, quote_id, product_data, store_view=None): """ Allows you to add one or more products to the shopping cart (quote). :param quote_id: Shopping cart ID (quote ID) :param product_data, list of dicts of product details, example [ { ...
[ "def", "add", "(", "self", ",", "quote_id", ",", "product_data", ",", "store_view", "=", "None", ")", ":", "return", "bool", "(", "self", ".", "call", "(", "'cart_product.add'", ",", "[", "quote_id", ",", "product_data", ",", "store_view", "]", ")", ")" ...
Allows you to add one or more products to the shopping cart (quote). :param quote_id: Shopping cart ID (quote ID) :param product_data, list of dicts of product details, example [ { 'product_id': 1, 'qty': 2, 'option...
[ "Allows", "you", "to", "add", "one", "or", "more", "products", "to", "the", "shopping", "cart", "(", "quote", ")", "." ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/checkout.py#L225-L255
fulfilio/python-magento
magento/checkout.py
CartProduct.move_to_customer_quote
def move_to_customer_quote(self, quote_id, product_data, store_view=None): """ Allows you to move products from the current quote to a customer quote. :param quote_id: Shopping cart ID (quote ID) :param product_data, list of dicts of product details, example [ ...
python
def move_to_customer_quote(self, quote_id, product_data, store_view=None): """ Allows you to move products from the current quote to a customer quote. :param quote_id: Shopping cart ID (quote ID) :param product_data, list of dicts of product details, example [ ...
[ "def", "move_to_customer_quote", "(", "self", ",", "quote_id", ",", "product_data", ",", "store_view", "=", "None", ")", ":", "return", "bool", "(", "self", ".", "call", "(", "'cart_product.moveToCustomerQuote'", ",", "[", "quote_id", ",", "product_data", ",", ...
Allows you to move products from the current quote to a customer quote. :param quote_id: Shopping cart ID (quote ID) :param product_data, list of dicts of product details, example [ { 'product_id': 1, 'qty': 2, 'opt...
[ "Allows", "you", "to", "move", "products", "from", "the", "current", "quote", "to", "a", "customer", "quote", "." ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/checkout.py#L277-L307
fulfilio/python-magento
magento/checkout.py
CartProduct.remove
def remove(self, quote_id, product_data, store_view=None): """ Allows you to remove one or several products from a shopping cart (quote). :param quote_id: Shopping cart ID (quote ID) :param product_data, list of dicts of product details, see def add() :param store_view: ...
python
def remove(self, quote_id, product_data, store_view=None): """ Allows you to remove one or several products from a shopping cart (quote). :param quote_id: Shopping cart ID (quote ID) :param product_data, list of dicts of product details, see def add() :param store_view: ...
[ "def", "remove", "(", "self", ",", "quote_id", ",", "product_data", ",", "store_view", "=", "None", ")", ":", "return", "bool", "(", "self", ".", "call", "(", "'cart_product.remove'", ",", "[", "quote_id", ",", "product_data", ",", "store_view", "]", ")", ...
Allows you to remove one or several products from a shopping cart (quote). :param quote_id: Shopping cart ID (quote ID) :param product_data, list of dicts of product details, see def add() :param store_view: Store view ID or code :return: boolean, True if the product is removed
[ "Allows", "you", "to", "remove", "one", "or", "several", "products", "from", "a", "shopping", "cart", "(", "quote", ")", "." ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/checkout.py#L312-L325
fulfilio/python-magento
magento/checkout.py
CartProduct.update
def update(self, quote_id, product_data, store_view=None): """ Allows you to update one or several products in the shopping cart (quote). :param quote_id: Shopping cart ID (quote ID) :param product_data, list of dicts of product details, see def add() :param store_view: ...
python
def update(self, quote_id, product_data, store_view=None): """ Allows you to update one or several products in the shopping cart (quote). :param quote_id: Shopping cart ID (quote ID) :param product_data, list of dicts of product details, see def add() :param store_view: ...
[ "def", "update", "(", "self", ",", "quote_id", ",", "product_data", ",", "store_view", "=", "None", ")", ":", "return", "bool", "(", "self", ".", "call", "(", "'cart_product.update'", ",", "[", "quote_id", ",", "product_data", ",", "store_view", "]", ")", ...
Allows you to update one or several products in the shopping cart (quote). :param quote_id: Shopping cart ID (quote ID) :param product_data, list of dicts of product details, see def add() :param store_view: Store view ID or code :return: boolean, True if the product is updated ...
[ "Allows", "you", "to", "update", "one", "or", "several", "products", "in", "the", "shopping", "cart", "(", "quote", ")", "." ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/checkout.py#L327-L340
fulfilio/python-magento
magento/checkout.py
CartShipping.method
def method(self, quote_id, shipping_method, store_view=None): """ Allows you to set a shipping method for a shopping cart (quote). :param quote_id: Shopping cart ID (quote ID) :param shipping_method, string, shipping method code :param store_view: Store view ID or code :...
python
def method(self, quote_id, shipping_method, store_view=None): """ Allows you to set a shipping method for a shopping cart (quote). :param quote_id: Shopping cart ID (quote ID) :param shipping_method, string, shipping method code :param store_view: Store view ID or code :...
[ "def", "method", "(", "self", ",", "quote_id", ",", "shipping_method", ",", "store_view", "=", "None", ")", ":", "return", "bool", "(", "self", ".", "call", "(", "'cart_shipping.method'", ",", "[", "quote_id", ",", "shipping_method", ",", "store_view", "]", ...
Allows you to set a shipping method for a shopping cart (quote). :param quote_id: Shopping cart ID (quote ID) :param shipping_method, string, shipping method code :param store_view: Store view ID or code :return: boolean, True if the shipping method is set
[ "Allows", "you", "to", "set", "a", "shipping", "method", "for", "a", "shopping", "cart", "(", "quote", ")", "." ]
train
https://github.com/fulfilio/python-magento/blob/720ec136a6e438a9ee4ee92848a9820b91732750/magento/checkout.py#L360-L372
sarugaku/passa
tasks/package.py
pack
def pack(ctx, remove_lib=True): """Build a isolated runnable package. """ OUTPUT_DIR.mkdir(parents=True, exist_ok=True) with ROOT.joinpath('Pipfile.lock').open() as f: lockfile = plette.Lockfile.load(f) libdir = OUTPUT_DIR.joinpath('lib') paths = {'purelib': libdir, 'platlib': libdir} ...
python
def pack(ctx, remove_lib=True): """Build a isolated runnable package. """ OUTPUT_DIR.mkdir(parents=True, exist_ok=True) with ROOT.joinpath('Pipfile.lock').open() as f: lockfile = plette.Lockfile.load(f) libdir = OUTPUT_DIR.joinpath('lib') paths = {'purelib': libdir, 'platlib': libdir} ...
[ "def", "pack", "(", "ctx", ",", "remove_lib", "=", "True", ")", ":", "OUTPUT_DIR", ".", "mkdir", "(", "parents", "=", "True", ",", "exist_ok", "=", "True", ")", "with", "ROOT", ".", "joinpath", "(", "'Pipfile.lock'", ")", ".", "open", "(", ")", "as",...
Build a isolated runnable package.
[ "Build", "a", "isolated", "runnable", "package", "." ]
train
https://github.com/sarugaku/passa/blob/a2ba0b30c86339cae5ef3a03046fc9c583452c40/tasks/package.py#L57-L97
sarugaku/passa
tasks/admin.py
release
def release(ctx, type_, repo=None, prebump_to=PREBUMP): """Make a new release. """ unprebump(ctx) if bump_release(ctx, type_=type_): return this_version = _read_version() ctx.run('towncrier') ctx.run(f'git commit -am "Release {this_version}"') ctx.run(f'git tag -fa {this_version...
python
def release(ctx, type_, repo=None, prebump_to=PREBUMP): """Make a new release. """ unprebump(ctx) if bump_release(ctx, type_=type_): return this_version = _read_version() ctx.run('towncrier') ctx.run(f'git commit -am "Release {this_version}"') ctx.run(f'git tag -fa {this_version...
[ "def", "release", "(", "ctx", ",", "type_", ",", "repo", "=", "None", ",", "prebump_to", "=", "PREBUMP", ")", ":", "unprebump", "(", "ctx", ")", "if", "bump_release", "(", "ctx", ",", "type_", "=", "type_", ")", ":", "return", "this_version", "=", "_...
Make a new release.
[ "Make", "a", "new", "release", "." ]
train
https://github.com/sarugaku/passa/blob/a2ba0b30c86339cae5ef3a03046fc9c583452c40/tasks/admin.py#L123-L144
dkruchinin/sanic-prometheus
sanic_prometheus/__init__.py
monitor
def monitor(app, endpoint_type='url:1', get_endpoint_fn=None, latency_buckets=None, mmc_period_sec=30, multiprocess_mode='all'): """ Regiesters a bunch of metrics for Sanic server (request latency, count, etc) and exposes /metrics endpoint to allow Prometh...
python
def monitor(app, endpoint_type='url:1', get_endpoint_fn=None, latency_buckets=None, mmc_period_sec=30, multiprocess_mode='all'): """ Regiesters a bunch of metrics for Sanic server (request latency, count, etc) and exposes /metrics endpoint to allow Prometh...
[ "def", "monitor", "(", "app", ",", "endpoint_type", "=", "'url:1'", ",", "get_endpoint_fn", "=", "None", ",", "latency_buckets", "=", "None", ",", "mmc_period_sec", "=", "30", ",", "multiprocess_mode", "=", "'all'", ")", ":", "multiprocess_on", "=", "'promethe...
Regiesters a bunch of metrics for Sanic server (request latency, count, etc) and exposes /metrics endpoint to allow Prometheus to scrape them out. :param app: an instance of sanic.app :param endpoint_type: All request related metrics have a label called 'endpoint'. It can be fe...
[ "Regiesters", "a", "bunch", "of", "metrics", "for", "Sanic", "server", "(", "request", "latency", "count", "etc", ")", "and", "exposes", "/", "metrics", "endpoint", "to", "allow", "Prometheus", "to", "scrape", "them", "out", "." ]
train
https://github.com/dkruchinin/sanic-prometheus/blob/fc0c2d337e8fc5e57960f152d06d5eb824678fd0/sanic_prometheus/__init__.py#L59-L134
dkruchinin/sanic-prometheus
sanic_prometheus/__init__.py
MonitorSetup.expose_endpoint
def expose_endpoint(self): """ Expose /metrics endpoint on the same Sanic server. This may be useful if Sanic is launched from a container and you do not want to expose more than one port for some reason. """ @self._app.route('/metrics', methods=['GET']) ...
python
def expose_endpoint(self): """ Expose /metrics endpoint on the same Sanic server. This may be useful if Sanic is launched from a container and you do not want to expose more than one port for some reason. """ @self._app.route('/metrics', methods=['GET']) ...
[ "def", "expose_endpoint", "(", "self", ")", ":", "@", "self", ".", "_app", ".", "route", "(", "'/metrics'", ",", "methods", "=", "[", "'GET'", "]", ")", "async", "def", "expose_metrics", "(", "request", ")", ":", "return", "raw", "(", "self", ".", "_...
Expose /metrics endpoint on the same Sanic server. This may be useful if Sanic is launched from a container and you do not want to expose more than one port for some reason.
[ "Expose", "/", "metrics", "endpoint", "on", "the", "same", "Sanic", "server", "." ]
train
https://github.com/dkruchinin/sanic-prometheus/blob/fc0c2d337e8fc5e57960f152d06d5eb824678fd0/sanic_prometheus/__init__.py#L20-L31
dkruchinin/sanic-prometheus
sanic_prometheus/__init__.py
MonitorSetup.start_server
def start_server(self, addr='', port=8000): """ Expose /metrics endpoint on a new server that will be launched on `<addr>:<port>`. This may be useful if you want to restrict access to metrics data with firewall rules. NOTE: can not be used in multiprocessing mode ...
python
def start_server(self, addr='', port=8000): """ Expose /metrics endpoint on a new server that will be launched on `<addr>:<port>`. This may be useful if you want to restrict access to metrics data with firewall rules. NOTE: can not be used in multiprocessing mode ...
[ "def", "start_server", "(", "self", ",", "addr", "=", "''", ",", "port", "=", "8000", ")", ":", "if", "self", ".", "_multiprocess_on", ":", "raise", "SanicPrometheusError", "(", "\"start_server can not be used when multiprocessing \"", "+", "\"is turned on\"", ")", ...
Expose /metrics endpoint on a new server that will be launched on `<addr>:<port>`. This may be useful if you want to restrict access to metrics data with firewall rules. NOTE: can not be used in multiprocessing mode
[ "Expose", "/", "metrics", "endpoint", "on", "a", "new", "server", "that", "will", "be", "launched", "on", "<addr", ">", ":", "<port", ">", "." ]
train
https://github.com/dkruchinin/sanic-prometheus/blob/fc0c2d337e8fc5e57960f152d06d5eb824678fd0/sanic_prometheus/__init__.py#L33-L46
remix/partridge
partridge/writers.py
extract_feed
def extract_feed( inpath: str, outpath: str, view: View, config: nx.DiGraph = None ) -> str: """Extract a subset of a GTFS zip into a new file""" config = default_config() if config is None else config config = remove_node_attributes(config, "converters") feed = load_feed(inpath, view, config) r...
python
def extract_feed( inpath: str, outpath: str, view: View, config: nx.DiGraph = None ) -> str: """Extract a subset of a GTFS zip into a new file""" config = default_config() if config is None else config config = remove_node_attributes(config, "converters") feed = load_feed(inpath, view, config) r...
[ "def", "extract_feed", "(", "inpath", ":", "str", ",", "outpath", ":", "str", ",", "view", ":", "View", ",", "config", ":", "nx", ".", "DiGraph", "=", "None", ")", "->", "str", ":", "config", "=", "default_config", "(", ")", "if", "config", "is", "...
Extract a subset of a GTFS zip into a new file
[ "Extract", "a", "subset", "of", "a", "GTFS", "zip", "into", "a", "new", "file" ]
train
https://github.com/remix/partridge/blob/0ba80fa30035e5e09fd8d7a7bdf1f28b93d53d03/partridge/writers.py#L19-L26
remix/partridge
partridge/writers.py
write_feed_dangerously
def write_feed_dangerously( feed: Feed, outpath: str, nodes: Optional[Collection[str]] = None ) -> str: """Naively write a feed to a zipfile This function provides no sanity checks. Use it at your own risk. """ nodes = DEFAULT_NODES if nodes is None else nodes try: tmpdir = tempfile...
python
def write_feed_dangerously( feed: Feed, outpath: str, nodes: Optional[Collection[str]] = None ) -> str: """Naively write a feed to a zipfile This function provides no sanity checks. Use it at your own risk. """ nodes = DEFAULT_NODES if nodes is None else nodes try: tmpdir = tempfile...
[ "def", "write_feed_dangerously", "(", "feed", ":", "Feed", ",", "outpath", ":", "str", ",", "nodes", ":", "Optional", "[", "Collection", "[", "str", "]", "]", "=", "None", ")", "->", "str", ":", "nodes", "=", "DEFAULT_NODES", "if", "nodes", "is", "None...
Naively write a feed to a zipfile This function provides no sanity checks. Use it at your own risk.
[ "Naively", "write", "a", "feed", "to", "a", "zipfile" ]
train
https://github.com/remix/partridge/blob/0ba80fa30035e5e09fd8d7a7bdf1f28b93d53d03/partridge/writers.py#L29-L60
remix/partridge
partridge/readers.py
read_busiest_date
def read_busiest_date(path: str) -> Tuple[datetime.date, FrozenSet[str]]: """Find the earliest date with the most trips""" feed = load_raw_feed(path) return _busiest_date(feed)
python
def read_busiest_date(path: str) -> Tuple[datetime.date, FrozenSet[str]]: """Find the earliest date with the most trips""" feed = load_raw_feed(path) return _busiest_date(feed)
[ "def", "read_busiest_date", "(", "path", ":", "str", ")", "->", "Tuple", "[", "datetime", ".", "date", ",", "FrozenSet", "[", "str", "]", "]", ":", "feed", "=", "load_raw_feed", "(", "path", ")", "return", "_busiest_date", "(", "feed", ")" ]
Find the earliest date with the most trips
[ "Find", "the", "earliest", "date", "with", "the", "most", "trips" ]
train
https://github.com/remix/partridge/blob/0ba80fa30035e5e09fd8d7a7bdf1f28b93d53d03/partridge/readers.py#L57-L60
remix/partridge
partridge/readers.py
read_busiest_week
def read_busiest_week(path: str) -> Dict[datetime.date, FrozenSet[str]]: """Find the earliest week with the most trips""" feed = load_raw_feed(path) return _busiest_week(feed)
python
def read_busiest_week(path: str) -> Dict[datetime.date, FrozenSet[str]]: """Find the earliest week with the most trips""" feed = load_raw_feed(path) return _busiest_week(feed)
[ "def", "read_busiest_week", "(", "path", ":", "str", ")", "->", "Dict", "[", "datetime", ".", "date", ",", "FrozenSet", "[", "str", "]", "]", ":", "feed", "=", "load_raw_feed", "(", "path", ")", "return", "_busiest_week", "(", "feed", ")" ]
Find the earliest week with the most trips
[ "Find", "the", "earliest", "week", "with", "the", "most", "trips" ]
train
https://github.com/remix/partridge/blob/0ba80fa30035e5e09fd8d7a7bdf1f28b93d53d03/partridge/readers.py#L63-L66
remix/partridge
partridge/readers.py
read_service_ids_by_date
def read_service_ids_by_date(path: str) -> Dict[datetime.date, FrozenSet[str]]: """Find all service identifiers by date""" feed = load_raw_feed(path) return _service_ids_by_date(feed)
python
def read_service_ids_by_date(path: str) -> Dict[datetime.date, FrozenSet[str]]: """Find all service identifiers by date""" feed = load_raw_feed(path) return _service_ids_by_date(feed)
[ "def", "read_service_ids_by_date", "(", "path", ":", "str", ")", "->", "Dict", "[", "datetime", ".", "date", ",", "FrozenSet", "[", "str", "]", "]", ":", "feed", "=", "load_raw_feed", "(", "path", ")", "return", "_service_ids_by_date", "(", "feed", ")" ]
Find all service identifiers by date
[ "Find", "all", "service", "identifiers", "by", "date" ]
train
https://github.com/remix/partridge/blob/0ba80fa30035e5e09fd8d7a7bdf1f28b93d53d03/partridge/readers.py#L69-L72
remix/partridge
partridge/readers.py
read_dates_by_service_ids
def read_dates_by_service_ids( path: str ) -> Dict[FrozenSet[str], FrozenSet[datetime.date]]: """Find dates with identical service""" feed = load_raw_feed(path) return _dates_by_service_ids(feed)
python
def read_dates_by_service_ids( path: str ) -> Dict[FrozenSet[str], FrozenSet[datetime.date]]: """Find dates with identical service""" feed = load_raw_feed(path) return _dates_by_service_ids(feed)
[ "def", "read_dates_by_service_ids", "(", "path", ":", "str", ")", "->", "Dict", "[", "FrozenSet", "[", "str", "]", ",", "FrozenSet", "[", "datetime", ".", "date", "]", "]", ":", "feed", "=", "load_raw_feed", "(", "path", ")", "return", "_dates_by_service_i...
Find dates with identical service
[ "Find", "dates", "with", "identical", "service" ]
train
https://github.com/remix/partridge/blob/0ba80fa30035e5e09fd8d7a7bdf1f28b93d53d03/partridge/readers.py#L75-L80
remix/partridge
partridge/readers.py
read_trip_counts_by_date
def read_trip_counts_by_date(path: str) -> Dict[datetime.date, int]: """A useful proxy for busyness""" feed = load_raw_feed(path) return _trip_counts_by_date(feed)
python
def read_trip_counts_by_date(path: str) -> Dict[datetime.date, int]: """A useful proxy for busyness""" feed = load_raw_feed(path) return _trip_counts_by_date(feed)
[ "def", "read_trip_counts_by_date", "(", "path", ":", "str", ")", "->", "Dict", "[", "datetime", ".", "date", ",", "int", "]", ":", "feed", "=", "load_raw_feed", "(", "path", ")", "return", "_trip_counts_by_date", "(", "feed", ")" ]
A useful proxy for busyness
[ "A", "useful", "proxy", "for", "busyness" ]
train
https://github.com/remix/partridge/blob/0ba80fa30035e5e09fd8d7a7bdf1f28b93d53d03/partridge/readers.py#L83-L86
remix/partridge
partridge/readers.py
_load_feed
def _load_feed(path: str, view: View, config: nx.DiGraph) -> Feed: """Multi-file feed filtering""" config_ = remove_node_attributes(config, ["converters", "transformations"]) feed_ = Feed(path, view={}, config=config_) for filename, column_filters in view.items(): config_ = reroot_graph(config_,...
python
def _load_feed(path: str, view: View, config: nx.DiGraph) -> Feed: """Multi-file feed filtering""" config_ = remove_node_attributes(config, ["converters", "transformations"]) feed_ = Feed(path, view={}, config=config_) for filename, column_filters in view.items(): config_ = reroot_graph(config_,...
[ "def", "_load_feed", "(", "path", ":", "str", ",", "view", ":", "View", ",", "config", ":", "nx", ".", "DiGraph", ")", "->", "Feed", ":", "config_", "=", "remove_node_attributes", "(", "config", ",", "[", "\"converters\"", ",", "\"transformations\"", "]", ...
Multi-file feed filtering
[ "Multi", "-", "file", "feed", "filtering" ]
train
https://github.com/remix/partridge/blob/0ba80fa30035e5e09fd8d7a7bdf1f28b93d53d03/partridge/readers.py#L106-L114
remix/partridge
partridge/gtfs.py
Feed._filter
def _filter(self, filename: str, df: pd.DataFrame) -> pd.DataFrame: """Apply view filters""" view = self._view.get(filename) if view is None: return df for col, values in view.items(): # If applicable, filter this dataframe by the given set of values ...
python
def _filter(self, filename: str, df: pd.DataFrame) -> pd.DataFrame: """Apply view filters""" view = self._view.get(filename) if view is None: return df for col, values in view.items(): # If applicable, filter this dataframe by the given set of values ...
[ "def", "_filter", "(", "self", ",", "filename", ":", "str", ",", "df", ":", "pd", ".", "DataFrame", ")", "->", "pd", ".", "DataFrame", ":", "view", "=", "self", ".", "_view", ".", "get", "(", "filename", ")", "if", "view", "is", "None", ":", "ret...
Apply view filters
[ "Apply", "view", "filters" ]
train
https://github.com/remix/partridge/blob/0ba80fa30035e5e09fd8d7a7bdf1f28b93d53d03/partridge/gtfs.py#L114-L125
remix/partridge
partridge/gtfs.py
Feed._prune
def _prune(self, filename: str, df: pd.DataFrame) -> pd.DataFrame: """Depth-first search through the dependency graph and prune dependent DataFrames along the way. """ dependencies = [] for _, depf, data in self._config.out_edges(filename, data=True): deps = data.get(...
python
def _prune(self, filename: str, df: pd.DataFrame) -> pd.DataFrame: """Depth-first search through the dependency graph and prune dependent DataFrames along the way. """ dependencies = [] for _, depf, data in self._config.out_edges(filename, data=True): deps = data.get(...
[ "def", "_prune", "(", "self", ",", "filename", ":", "str", ",", "df", ":", "pd", ".", "DataFrame", ")", "->", "pd", ".", "DataFrame", ":", "dependencies", "=", "[", "]", "for", "_", ",", "depf", ",", "data", "in", "self", ".", "_config", ".", "ou...
Depth-first search through the dependency graph and prune dependent DataFrames along the way.
[ "Depth", "-", "first", "search", "through", "the", "dependency", "graph", "and", "prune", "dependent", "DataFrames", "along", "the", "way", "." ]
train
https://github.com/remix/partridge/blob/0ba80fa30035e5e09fd8d7a7bdf1f28b93d53d03/partridge/gtfs.py#L127-L152
remix/partridge
partridge/gtfs.py
Feed._convert_types
def _convert_types(self, filename: str, df: pd.DataFrame) -> None: """ Apply type conversions """ if df.empty: return converters = self._config.nodes.get(filename, {}).get("converters", {}) for col, converter in converters.items(): if col in df.co...
python
def _convert_types(self, filename: str, df: pd.DataFrame) -> None: """ Apply type conversions """ if df.empty: return converters = self._config.nodes.get(filename, {}).get("converters", {}) for col, converter in converters.items(): if col in df.co...
[ "def", "_convert_types", "(", "self", ",", "filename", ":", "str", ",", "df", ":", "pd", ".", "DataFrame", ")", "->", "None", ":", "if", "df", ".", "empty", ":", "return", "converters", "=", "self", ".", "_config", ".", "nodes", ".", "get", "(", "f...
Apply type conversions
[ "Apply", "type", "conversions" ]
train
https://github.com/remix/partridge/blob/0ba80fa30035e5e09fd8d7a7bdf1f28b93d53d03/partridge/gtfs.py#L154-L164
remix/partridge
partridge/config.py
reroot_graph
def reroot_graph(G: nx.DiGraph, node: str) -> nx.DiGraph: """Return a copy of the graph rooted at the given node""" G = G.copy() for n, successors in list(nx.bfs_successors(G, source=node)): for s in successors: G.add_edge(s, n, **G.edges[n, s]) G.remove_edge(n, s) return...
python
def reroot_graph(G: nx.DiGraph, node: str) -> nx.DiGraph: """Return a copy of the graph rooted at the given node""" G = G.copy() for n, successors in list(nx.bfs_successors(G, source=node)): for s in successors: G.add_edge(s, n, **G.edges[n, s]) G.remove_edge(n, s) return...
[ "def", "reroot_graph", "(", "G", ":", "nx", ".", "DiGraph", ",", "node", ":", "str", ")", "->", "nx", ".", "DiGraph", ":", "G", "=", "G", ".", "copy", "(", ")", "for", "n", ",", "successors", "in", "list", "(", "nx", ".", "bfs_successors", "(", ...
Return a copy of the graph rooted at the given node
[ "Return", "a", "copy", "of", "the", "graph", "rooted", "at", "the", "given", "node" ]
train
https://github.com/remix/partridge/blob/0ba80fa30035e5e09fd8d7a7bdf1f28b93d53d03/partridge/config.py#L339-L346
remix/partridge
partridge/utilities.py
setwrap
def setwrap(value: Any) -> Set[str]: """ Returns a flattened and stringified set from the given object or iterable. For use in public functions which accept argmuents or kwargs that can be one object or a list of objects. """ return set(map(str, set(flatten([value]))))
python
def setwrap(value: Any) -> Set[str]: """ Returns a flattened and stringified set from the given object or iterable. For use in public functions which accept argmuents or kwargs that can be one object or a list of objects. """ return set(map(str, set(flatten([value]))))
[ "def", "setwrap", "(", "value", ":", "Any", ")", "->", "Set", "[", "str", "]", ":", "return", "set", "(", "map", "(", "str", ",", "set", "(", "flatten", "(", "[", "value", "]", ")", ")", ")", ")" ]
Returns a flattened and stringified set from the given object or iterable. For use in public functions which accept argmuents or kwargs that can be one object or a list of objects.
[ "Returns", "a", "flattened", "and", "stringified", "set", "from", "the", "given", "object", "or", "iterable", "." ]
train
https://github.com/remix/partridge/blob/0ba80fa30035e5e09fd8d7a7bdf1f28b93d53d03/partridge/utilities.py#L10-L17
remix/partridge
partridge/utilities.py
remove_node_attributes
def remove_node_attributes(G: nx.DiGraph, attributes: Union[str, Iterable[str]]): """ Return a copy of the graph with the given attributes deleted from all nodes. """ G = G.copy() for _, data in G.nodes(data=True): for attribute in setwrap(attributes): if attribute in data: ...
python
def remove_node_attributes(G: nx.DiGraph, attributes: Union[str, Iterable[str]]): """ Return a copy of the graph with the given attributes deleted from all nodes. """ G = G.copy() for _, data in G.nodes(data=True): for attribute in setwrap(attributes): if attribute in data: ...
[ "def", "remove_node_attributes", "(", "G", ":", "nx", ".", "DiGraph", ",", "attributes", ":", "Union", "[", "str", ",", "Iterable", "[", "str", "]", "]", ")", ":", "G", "=", "G", ".", "copy", "(", ")", "for", "_", ",", "data", "in", "G", ".", "...
Return a copy of the graph with the given attributes deleted from all nodes.
[ "Return", "a", "copy", "of", "the", "graph", "with", "the", "given", "attributes", "deleted", "from", "all", "nodes", "." ]
train
https://github.com/remix/partridge/blob/0ba80fa30035e5e09fd8d7a7bdf1f28b93d53d03/partridge/utilities.py#L20-L30
ciena/afkak
afkak/_util.py
_coerce_topic
def _coerce_topic(topic): """ Ensure that the topic name is text string of a valid length. :param topic: Kafka topic name. Valid characters are in the set ``[a-zA-Z0-9._-]``. :raises ValueError: when the topic name exceeds 249 bytes :raises TypeError: when the topic is not :class:`unicode` or :clas...
python
def _coerce_topic(topic): """ Ensure that the topic name is text string of a valid length. :param topic: Kafka topic name. Valid characters are in the set ``[a-zA-Z0-9._-]``. :raises ValueError: when the topic name exceeds 249 bytes :raises TypeError: when the topic is not :class:`unicode` or :clas...
[ "def", "_coerce_topic", "(", "topic", ")", ":", "if", "not", "isinstance", "(", "topic", ",", "string_types", ")", ":", "raise", "TypeError", "(", "'topic={!r} must be text'", ".", "format", "(", "topic", ")", ")", "if", "not", "isinstance", "(", "topic", ...
Ensure that the topic name is text string of a valid length. :param topic: Kafka topic name. Valid characters are in the set ``[a-zA-Z0-9._-]``. :raises ValueError: when the topic name exceeds 249 bytes :raises TypeError: when the topic is not :class:`unicode` or :class:`str`
[ "Ensure", "that", "the", "topic", "name", "is", "text", "string", "of", "a", "valid", "length", "." ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/_util.py#L27-L44
ciena/afkak
afkak/_util.py
_coerce_consumer_group
def _coerce_consumer_group(consumer_group): """ Ensure that the consumer group is a text string. :param consumer_group: :class:`bytes` or :class:`str` instance :raises TypeError: when `consumer_group` is not :class:`bytes` or :class:`str` """ if not isinstance(consumer_group, string_typ...
python
def _coerce_consumer_group(consumer_group): """ Ensure that the consumer group is a text string. :param consumer_group: :class:`bytes` or :class:`str` instance :raises TypeError: when `consumer_group` is not :class:`bytes` or :class:`str` """ if not isinstance(consumer_group, string_typ...
[ "def", "_coerce_consumer_group", "(", "consumer_group", ")", ":", "if", "not", "isinstance", "(", "consumer_group", ",", "string_types", ")", ":", "raise", "TypeError", "(", "'consumer_group={!r} must be text'", ".", "format", "(", "consumer_group", ")", ")", "if", ...
Ensure that the consumer group is a text string. :param consumer_group: :class:`bytes` or :class:`str` instance :raises TypeError: when `consumer_group` is not :class:`bytes` or :class:`str`
[ "Ensure", "that", "the", "consumer", "group", "is", "a", "text", "string", "." ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/_util.py#L47-L59
ciena/afkak
afkak/_util.py
_coerce_client_id
def _coerce_client_id(client_id): """ Ensure the provided client ID is a byte string. If a text string is provided, it is encoded as UTF-8 bytes. :param client_id: :class:`bytes` or :class:`str` instance """ if isinstance(client_id, type(u'')): client_id = client_id.encode('utf-8') ...
python
def _coerce_client_id(client_id): """ Ensure the provided client ID is a byte string. If a text string is provided, it is encoded as UTF-8 bytes. :param client_id: :class:`bytes` or :class:`str` instance """ if isinstance(client_id, type(u'')): client_id = client_id.encode('utf-8') ...
[ "def", "_coerce_client_id", "(", "client_id", ")", ":", "if", "isinstance", "(", "client_id", ",", "type", "(", "u''", ")", ")", ":", "client_id", "=", "client_id", ".", "encode", "(", "'utf-8'", ")", "if", "not", "isinstance", "(", "client_id", ",", "by...
Ensure the provided client ID is a byte string. If a text string is provided, it is encoded as UTF-8 bytes. :param client_id: :class:`bytes` or :class:`str` instance
[ "Ensure", "the", "provided", "client", "ID", "is", "a", "byte", "string", ".", "If", "a", "text", "string", "is", "provided", "it", "is", "encoded", "as", "UTF", "-", "8", "bytes", "." ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/_util.py#L62-L74
ciena/afkak
afkak/_util.py
write_short_ascii
def write_short_ascii(s): """ Encode a Kafka short string which represents text. :param str s: Text string (`str` on Python 3, `str` or `unicode` on Python 2) or ``None``. The string will be ASCII-encoded. :returns: length-prefixed `bytes` :raises: `struct.error` for string...
python
def write_short_ascii(s): """ Encode a Kafka short string which represents text. :param str s: Text string (`str` on Python 3, `str` or `unicode` on Python 2) or ``None``. The string will be ASCII-encoded. :returns: length-prefixed `bytes` :raises: `struct.error` for string...
[ "def", "write_short_ascii", "(", "s", ")", ":", "if", "s", "is", "None", ":", "return", "_NULL_SHORT_STRING", "if", "not", "isinstance", "(", "s", ",", "string_types", ")", ":", "raise", "TypeError", "(", "'{!r} is not text'", ".", "format", "(", "s", ")",...
Encode a Kafka short string which represents text. :param str s: Text string (`str` on Python 3, `str` or `unicode` on Python 2) or ``None``. The string will be ASCII-encoded. :returns: length-prefixed `bytes` :raises: `struct.error` for strings longer than 32767 characters
[ "Encode", "a", "Kafka", "short", "string", "which", "represents", "text", "." ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/_util.py#L83-L99
ciena/afkak
afkak/_util.py
write_short_bytes
def write_short_bytes(b): """ Encode a Kafka short string which contains arbitrary bytes. A short string is limited to 32767 bytes in length by the signed 16-bit length prefix. A length prefix of -1 indicates ``null``, represented as ``None`` in Python. :param bytes b: No more than 3276...
python
def write_short_bytes(b): """ Encode a Kafka short string which contains arbitrary bytes. A short string is limited to 32767 bytes in length by the signed 16-bit length prefix. A length prefix of -1 indicates ``null``, represented as ``None`` in Python. :param bytes b: No more than 3276...
[ "def", "write_short_bytes", "(", "b", ")", ":", "if", "b", "is", "None", ":", "return", "_NULL_SHORT_STRING", "if", "not", "isinstance", "(", "b", ",", "bytes", ")", ":", "raise", "TypeError", "(", "'{!r} is not bytes'", ".", "format", "(", "b", ")", ")"...
Encode a Kafka short string which contains arbitrary bytes. A short string is limited to 32767 bytes in length by the signed 16-bit length prefix. A length prefix of -1 indicates ``null``, represented as ``None`` in Python. :param bytes b: No more than 32767 bytes, or ``None`` for the null enco...
[ "Encode", "a", "Kafka", "short", "string", "which", "contains", "arbitrary", "bytes", ".", "A", "short", "string", "is", "limited", "to", "32767", "bytes", "in", "length", "by", "the", "signed", "16", "-", "bit", "length", "prefix", ".", "A", "length", "...
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/_util.py#L102-L122
Salamek/cron-descriptor
examples/crontabReader.py
CrontabReader.parse_cron_line
def parse_cron_line(self, line): """Parses crontab line and returns only starting time string Args: line: crontab line Returns: Time part of cron line """ stripped = line.strip() if stripped and stripped.startswith('#') is False: rexr...
python
def parse_cron_line(self, line): """Parses crontab line and returns only starting time string Args: line: crontab line Returns: Time part of cron line """ stripped = line.strip() if stripped and stripped.startswith('#') is False: rexr...
[ "def", "parse_cron_line", "(", "self", ",", "line", ")", ":", "stripped", "=", "line", ".", "strip", "(", ")", "if", "stripped", "and", "stripped", ".", "startswith", "(", "'#'", ")", "is", "False", ":", "rexres", "=", "self", ".", "rex", ".", "searc...
Parses crontab line and returns only starting time string Args: line: crontab line Returns: Time part of cron line
[ "Parses", "crontab", "line", "and", "returns", "only", "starting", "time", "string" ]
train
https://github.com/Salamek/cron-descriptor/blob/fafe86b33e190caf205836fa1c719d27c7b408c7/examples/crontabReader.py#L58-L73
ciena/afkak
afkak/brokerclient.py
_KafkaBrokerClient.updateMetadata
def updateMetadata(self, new): """ Update the metadata stored for this broker. Future connections made to the broker will use the host and port defined in the new metadata. Any existing connection is not dropped, however. :param new: :clas:`afkak.common.Brok...
python
def updateMetadata(self, new): """ Update the metadata stored for this broker. Future connections made to the broker will use the host and port defined in the new metadata. Any existing connection is not dropped, however. :param new: :clas:`afkak.common.Brok...
[ "def", "updateMetadata", "(", "self", ",", "new", ")", ":", "if", "self", ".", "node_id", "!=", "new", ".", "node_id", ":", "raise", "ValueError", "(", "\"Broker metadata {!r} doesn't match node_id={}\"", ".", "format", "(", "new", ",", "self", ".", "node_id",...
Update the metadata stored for this broker. Future connections made to the broker will use the host and port defined in the new metadata. Any existing connection is not dropped, however. :param new: :clas:`afkak.common.BrokerMetadata` with the same node ID as the ...
[ "Update", "the", "metadata", "stored", "for", "this", "broker", "." ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/brokerclient.py#L130-L147
ciena/afkak
afkak/brokerclient.py
_KafkaBrokerClient.makeRequest
def makeRequest(self, requestId, request, expectResponse=True): """ Send a request to our broker via our self.proto KafkaProtocol object. Return a deferred which will fire when the reply matching the requestId comes back from the server, or, if expectResponse is False, then retu...
python
def makeRequest(self, requestId, request, expectResponse=True): """ Send a request to our broker via our self.proto KafkaProtocol object. Return a deferred which will fire when the reply matching the requestId comes back from the server, or, if expectResponse is False, then retu...
[ "def", "makeRequest", "(", "self", ",", "requestId", ",", "request", ",", "expectResponse", "=", "True", ")", ":", "if", "requestId", "in", "self", ".", "requests", ":", "# Id is duplicate to 'in-flight' request. Reject it, as we", "# won't be able to properly deliver the...
Send a request to our broker via our self.proto KafkaProtocol object. Return a deferred which will fire when the reply matching the requestId comes back from the server, or, if expectResponse is False, then return None instead. If we are not currently connected, then we buffer the reque...
[ "Send", "a", "request", "to", "our", "broker", "via", "our", "self", ".", "proto", "KafkaProtocol", "object", "." ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/brokerclient.py#L149-L194
ciena/afkak
afkak/brokerclient.py
_KafkaBrokerClient.disconnect
def disconnect(self): """ Disconnect from the Kafka broker. This is used to implement disconnection on timeout as a workaround for Kafka connections occasionally getting stuck on the server side under load. Requests are not cancelled, so they will be retried. """ ...
python
def disconnect(self): """ Disconnect from the Kafka broker. This is used to implement disconnection on timeout as a workaround for Kafka connections occasionally getting stuck on the server side under load. Requests are not cancelled, so they will be retried. """ ...
[ "def", "disconnect", "(", "self", ")", ":", "if", "self", ".", "proto", ":", "log", ".", "debug", "(", "'%r Disconnecting from %r'", ",", "self", ",", "self", ".", "proto", ".", "transport", ".", "getPeer", "(", ")", ")", "self", ".", "proto", ".", "...
Disconnect from the Kafka broker. This is used to implement disconnection on timeout as a workaround for Kafka connections occasionally getting stuck on the server side under load. Requests are not cancelled, so they will be retried.
[ "Disconnect", "from", "the", "Kafka", "broker", "." ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/brokerclient.py#L196-L206
ciena/afkak
afkak/brokerclient.py
_KafkaBrokerClient.close
def close(self): """Permanently dispose of the broker client. This terminates any outstanding connection and cancels any pending requests. """ log.debug('%r: close() proto=%r connector=%r', self, self.proto, self.connector) assert self._dDown is None self._dDown ...
python
def close(self): """Permanently dispose of the broker client. This terminates any outstanding connection and cancels any pending requests. """ log.debug('%r: close() proto=%r connector=%r', self, self.proto, self.connector) assert self._dDown is None self._dDown ...
[ "def", "close", "(", "self", ")", ":", "log", ".", "debug", "(", "'%r: close() proto=%r connector=%r'", ",", "self", ",", "self", ".", "proto", ",", "self", ".", "connector", ")", "assert", "self", ".", "_dDown", "is", "None", "self", ".", "_dDown", "=",...
Permanently dispose of the broker client. This terminates any outstanding connection and cancels any pending requests.
[ "Permanently", "dispose", "of", "the", "broker", "client", "." ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/brokerclient.py#L208-L246
ciena/afkak
afkak/brokerclient.py
_KafkaBrokerClient._connectionLost
def _connectionLost(self, reason): """Called when the protocol connection is lost - Log the disconnection. - Mark any outstanding requests as unsent so they will be sent when a new connection is made. - If closing the broker client, mark completion of that process. :p...
python
def _connectionLost(self, reason): """Called when the protocol connection is lost - Log the disconnection. - Mark any outstanding requests as unsent so they will be sent when a new connection is made. - If closing the broker client, mark completion of that process. :p...
[ "def", "_connectionLost", "(", "self", ",", "reason", ")", ":", "log", ".", "info", "(", "'%r: Connection closed: %r'", ",", "self", ",", "reason", ")", "# Reset our proto so we don't try to send to a down connection", "self", ".", "proto", "=", "None", "# Mark any in...
Called when the protocol connection is lost - Log the disconnection. - Mark any outstanding requests as unsent so they will be sent when a new connection is made. - If closing the broker client, mark completion of that process. :param reason: Failure that indicate...
[ "Called", "when", "the", "protocol", "connection", "is", "lost" ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/brokerclient.py#L252-L275
ciena/afkak
afkak/brokerclient.py
_KafkaBrokerClient.handleResponse
def handleResponse(self, response): """Handle the response string received by KafkaProtocol. Ok, we've received the response from the broker. Find the requestId in the message, lookup & fire the deferred with the response. """ requestId = KafkaCodec.get_response_correlation_id(r...
python
def handleResponse(self, response): """Handle the response string received by KafkaProtocol. Ok, we've received the response from the broker. Find the requestId in the message, lookup & fire the deferred with the response. """ requestId = KafkaCodec.get_response_correlation_id(r...
[ "def", "handleResponse", "(", "self", ",", "response", ")", ":", "requestId", "=", "KafkaCodec", ".", "get_response_correlation_id", "(", "response", ")", "# Protect against responses coming back we didn't expect", "tReq", "=", "self", ".", "requests", ".", "pop", "("...
Handle the response string received by KafkaProtocol. Ok, we've received the response from the broker. Find the requestId in the message, lookup & fire the deferred with the response.
[ "Handle", "the", "response", "string", "received", "by", "KafkaProtocol", "." ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/brokerclient.py#L277-L292
ciena/afkak
afkak/brokerclient.py
_KafkaBrokerClient._sendRequest
def _sendRequest(self, tReq): """Send a single request over our protocol to the Kafka broker.""" try: tReq.sent = True self.proto.sendString(tReq.data) except Exception as e: log.exception('%r: Failed to send request %r', self, tReq) del self.reque...
python
def _sendRequest(self, tReq): """Send a single request over our protocol to the Kafka broker.""" try: tReq.sent = True self.proto.sendString(tReq.data) except Exception as e: log.exception('%r: Failed to send request %r', self, tReq) del self.reque...
[ "def", "_sendRequest", "(", "self", ",", "tReq", ")", ":", "try", ":", "tReq", ".", "sent", "=", "True", "self", ".", "proto", ".", "sendString", "(", "tReq", ".", "data", ")", "except", "Exception", "as", "e", ":", "log", ".", "exception", "(", "'...
Send a single request over our protocol to the Kafka broker.
[ "Send", "a", "single", "request", "over", "our", "protocol", "to", "the", "Kafka", "broker", "." ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/brokerclient.py#L296-L311
ciena/afkak
afkak/brokerclient.py
_KafkaBrokerClient._sendQueued
def _sendQueued(self): """Connection just came up, send the unsent requests.""" for tReq in list(self.requests.values()): # must copy, may del if not tReq.sent: self._sendRequest(tReq)
python
def _sendQueued(self): """Connection just came up, send the unsent requests.""" for tReq in list(self.requests.values()): # must copy, may del if not tReq.sent: self._sendRequest(tReq)
[ "def", "_sendQueued", "(", "self", ")", ":", "for", "tReq", "in", "list", "(", "self", ".", "requests", ".", "values", "(", ")", ")", ":", "# must copy, may del", "if", "not", "tReq", ".", "sent", ":", "self", ".", "_sendRequest", "(", "tReq", ")" ]
Connection just came up, send the unsent requests.
[ "Connection", "just", "came", "up", "send", "the", "unsent", "requests", "." ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/brokerclient.py#L313-L317
ciena/afkak
afkak/brokerclient.py
_KafkaBrokerClient.cancelRequest
def cancelRequest(self, requestId, reason=None, _=None): """Cancel a request: remove it from requests, & errback the deferred. NOTE: Attempts to cancel a request which is no longer tracked (expectResponse == False and already sent, or response already received) will raise KeyError ...
python
def cancelRequest(self, requestId, reason=None, _=None): """Cancel a request: remove it from requests, & errback the deferred. NOTE: Attempts to cancel a request which is no longer tracked (expectResponse == False and already sent, or response already received) will raise KeyError ...
[ "def", "cancelRequest", "(", "self", ",", "requestId", ",", "reason", "=", "None", ",", "_", "=", "None", ")", ":", "if", "reason", "is", "None", ":", "reason", "=", "CancelledError", "(", ")", "tReq", "=", "self", ".", "requests", ".", "pop", "(", ...
Cancel a request: remove it from requests, & errback the deferred. NOTE: Attempts to cancel a request which is no longer tracked (expectResponse == False and already sent, or response already received) will raise KeyError
[ "Cancel", "a", "request", ":", "remove", "it", "from", "requests", "&", "errback", "the", "deferred", "." ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/brokerclient.py#L322-L332
ciena/afkak
afkak/brokerclient.py
_KafkaBrokerClient._connect
def _connect(self): """Connect to the Kafka Broker This routine will repeatedly try to connect to the broker (with backoff according to the retry policy) until it succeeds. """ def tryConnect(): self.connector = d = maybeDeferred(connect) d.addCallback(cb...
python
def _connect(self): """Connect to the Kafka Broker This routine will repeatedly try to connect to the broker (with backoff according to the retry policy) until it succeeds. """ def tryConnect(): self.connector = d = maybeDeferred(connect) d.addCallback(cb...
[ "def", "_connect", "(", "self", ")", ":", "def", "tryConnect", "(", ")", ":", "self", ".", "connector", "=", "d", "=", "maybeDeferred", "(", "connect", ")", "d", ".", "addCallback", "(", "cbConnect", ")", "d", ".", "addErrback", "(", "ebConnect", ")", ...
Connect to the Kafka Broker This routine will repeatedly try to connect to the broker (with backoff according to the retry policy) until it succeeds.
[ "Connect", "to", "the", "Kafka", "Broker" ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/brokerclient.py#L342-L384
Salamek/cron-descriptor
cron_descriptor/ExpressionParser.py
ExpressionParser.parse
def parse(self): """Parses the cron expression string Returns: A 7 part string array, one part for each component of the cron expression (seconds, minutes, etc.) Raises: MissingFieldException: if _expression is empty or None FormatException: if _expression has...
python
def parse(self): """Parses the cron expression string Returns: A 7 part string array, one part for each component of the cron expression (seconds, minutes, etc.) Raises: MissingFieldException: if _expression is empty or None FormatException: if _expression has...
[ "def", "parse", "(", "self", ")", ":", "# Initialize all elements of parsed array to empty strings", "parsed", "=", "[", "''", ",", "''", ",", "''", ",", "''", ",", "''", ",", "''", ",", "''", "]", "if", "self", ".", "_expression", "is", "None", "or", "l...
Parses the cron expression string Returns: A 7 part string array, one part for each component of the cron expression (seconds, minutes, etc.) Raises: MissingFieldException: if _expression is empty or None FormatException: if _expression has wrong format
[ "Parses", "the", "cron", "expression", "string", "Returns", ":", "A", "7", "part", "string", "array", "one", "part", "for", "each", "component", "of", "the", "cron", "expression", "(", "seconds", "minutes", "etc", ".", ")", "Raises", ":", "MissingFieldExcept...
train
https://github.com/Salamek/cron-descriptor/blob/fafe86b33e190caf205836fa1c719d27c7b408c7/cron_descriptor/ExpressionParser.py#L72-L114
Salamek/cron-descriptor
cron_descriptor/ExpressionParser.py
ExpressionParser.normalize_expression
def normalize_expression(self, expression_parts): """Converts cron expression components into consistent, predictable formats. Args: expression_parts: A 7 part string array, one part for each component of the cron expression Returns: None """ # convert ? t...
python
def normalize_expression(self, expression_parts): """Converts cron expression components into consistent, predictable formats. Args: expression_parts: A 7 part string array, one part for each component of the cron expression Returns: None """ # convert ? t...
[ "def", "normalize_expression", "(", "self", ",", "expression_parts", ")", ":", "# convert ? to * only for DOM and DOW", "expression_parts", "[", "3", "]", "=", "expression_parts", "[", "3", "]", ".", "replace", "(", "\"?\"", ",", "\"*\"", ")", "expression_parts", ...
Converts cron expression components into consistent, predictable formats. Args: expression_parts: A 7 part string array, one part for each component of the cron expression Returns: None
[ "Converts", "cron", "expression", "components", "into", "consistent", "predictable", "formats", ".", "Args", ":", "expression_parts", ":", "A", "7", "part", "string", "array", "one", "part", "for", "each", "component", "of", "the", "cron", "expression", "Returns...
train
https://github.com/Salamek/cron-descriptor/blob/fafe86b33e190caf205836fa1c719d27c7b408c7/cron_descriptor/ExpressionParser.py#L121-L206
ciena/afkak
tools/gentravis.py
group_envs
def group_envs(envlist): """Group Tox environments for Travis CI builds Separate by Python version so that they can go in different Travis jobs: >>> group_envs('py37-int-snappy', 'py36-int') [('py36', 'int', ['py36-int']), ('py37', 'int', ['py37-int-snappy'])] Group unit tests and linting togethe...
python
def group_envs(envlist): """Group Tox environments for Travis CI builds Separate by Python version so that they can go in different Travis jobs: >>> group_envs('py37-int-snappy', 'py36-int') [('py36', 'int', ['py36-int']), ('py37', 'int', ['py37-int-snappy'])] Group unit tests and linting togethe...
[ "def", "group_envs", "(", "envlist", ")", ":", "groups", "=", "{", "}", "for", "env", "in", "envlist", ":", "envpy", ",", "category", "=", "env", ".", "split", "(", "'-'", ")", "[", "0", ":", "2", "]", "if", "category", "==", "'lint'", ":", "cate...
Group Tox environments for Travis CI builds Separate by Python version so that they can go in different Travis jobs: >>> group_envs('py37-int-snappy', 'py36-int') [('py36', 'int', ['py36-int']), ('py37', 'int', ['py37-int-snappy'])] Group unit tests and linting together: >>> group_envs(['py27-un...
[ "Group", "Tox", "environments", "for", "Travis", "CI", "builds" ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/tools/gentravis.py#L70-L95
ciena/afkak
afkak/kafkacodec.py
create_message
def create_message(payload, key=None): """ Construct a :class:`Message` :param payload: The payload to send to Kafka. :type payload: :class:`bytes` or ``None`` :param key: A key used to route the message when partitioning and to determine message identity on a compacted topic. :type key...
python
def create_message(payload, key=None): """ Construct a :class:`Message` :param payload: The payload to send to Kafka. :type payload: :class:`bytes` or ``None`` :param key: A key used to route the message when partitioning and to determine message identity on a compacted topic. :type key...
[ "def", "create_message", "(", "payload", ",", "key", "=", "None", ")", ":", "assert", "payload", "is", "None", "or", "isinstance", "(", "payload", ",", "bytes", ")", ",", "'payload={!r} should be bytes or None'", ".", "format", "(", "payload", ")", "assert", ...
Construct a :class:`Message` :param payload: The payload to send to Kafka. :type payload: :class:`bytes` or ``None`` :param key: A key used to route the message when partitioning and to determine message identity on a compacted topic. :type key: :class:`bytes` or ``None``
[ "Construct", "a", ":", "class", ":", "Message" ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/kafkacodec.py#L580-L592
ciena/afkak
afkak/kafkacodec.py
create_gzip_message
def create_gzip_message(message_set): """ Construct a gzip-compressed message containing multiple messages The given messages will be encoded, compressed, and sent as a single atomic message to Kafka. :param list message_set: a list of :class:`Message` instances """ encoded_message_set = K...
python
def create_gzip_message(message_set): """ Construct a gzip-compressed message containing multiple messages The given messages will be encoded, compressed, and sent as a single atomic message to Kafka. :param list message_set: a list of :class:`Message` instances """ encoded_message_set = K...
[ "def", "create_gzip_message", "(", "message_set", ")", ":", "encoded_message_set", "=", "KafkaCodec", ".", "_encode_message_set", "(", "message_set", ")", "gzipped", "=", "gzip_encode", "(", "encoded_message_set", ")", "return", "Message", "(", "0", ",", "CODEC_GZIP...
Construct a gzip-compressed message containing multiple messages The given messages will be encoded, compressed, and sent as a single atomic message to Kafka. :param list message_set: a list of :class:`Message` instances
[ "Construct", "a", "gzip", "-", "compressed", "message", "containing", "multiple", "messages" ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/kafkacodec.py#L595-L607
ciena/afkak
afkak/kafkacodec.py
create_snappy_message
def create_snappy_message(message_set): """ Construct a Snappy-compressed message containing multiple messages The given messages will be encoded, compressed, and sent as a single atomic message to Kafka. :param list message_set: a list of :class:`Message` instances """ encoded_message_set...
python
def create_snappy_message(message_set): """ Construct a Snappy-compressed message containing multiple messages The given messages will be encoded, compressed, and sent as a single atomic message to Kafka. :param list message_set: a list of :class:`Message` instances """ encoded_message_set...
[ "def", "create_snappy_message", "(", "message_set", ")", ":", "encoded_message_set", "=", "KafkaCodec", ".", "_encode_message_set", "(", "message_set", ")", "snapped", "=", "snappy_encode", "(", "encoded_message_set", ")", "return", "Message", "(", "0", ",", "CODEC_...
Construct a Snappy-compressed message containing multiple messages The given messages will be encoded, compressed, and sent as a single atomic message to Kafka. :param list message_set: a list of :class:`Message` instances
[ "Construct", "a", "Snappy", "-", "compressed", "message", "containing", "multiple", "messages" ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/kafkacodec.py#L610-L621
ciena/afkak
afkak/kafkacodec.py
create_message_set
def create_message_set(requests, codec=CODEC_NONE): """ Create a message set from a list of requests. Each request can have a list of messages and its own key. If codec is :data:`CODEC_NONE`, return a list of raw Kafka messages. Otherwise, return a list containing a single codec-encoded message. ...
python
def create_message_set(requests, codec=CODEC_NONE): """ Create a message set from a list of requests. Each request can have a list of messages and its own key. If codec is :data:`CODEC_NONE`, return a list of raw Kafka messages. Otherwise, return a list containing a single codec-encoded message. ...
[ "def", "create_message_set", "(", "requests", ",", "codec", "=", "CODEC_NONE", ")", ":", "msglist", "=", "[", "]", "for", "req", "in", "requests", ":", "msglist", ".", "extend", "(", "[", "create_message", "(", "m", ",", "key", "=", "req", ".", "key", ...
Create a message set from a list of requests. Each request can have a list of messages and its own key. If codec is :data:`CODEC_NONE`, return a list of raw Kafka messages. Otherwise, return a list containing a single codec-encoded message. :param codec: The encoding for the message set, one ...
[ "Create", "a", "message", "set", "from", "a", "list", "of", "requests", "." ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/kafkacodec.py#L624-L652
ciena/afkak
afkak/kafkacodec.py
KafkaCodec._encode_message_header
def _encode_message_header(cls, client_id, correlation_id, request_key, api_version=0): """ Encode the common request envelope """ return (struct.pack('>hhih', request_key, # ApiKey api_versio...
python
def _encode_message_header(cls, client_id, correlation_id, request_key, api_version=0): """ Encode the common request envelope """ return (struct.pack('>hhih', request_key, # ApiKey api_versio...
[ "def", "_encode_message_header", "(", "cls", ",", "client_id", ",", "correlation_id", ",", "request_key", ",", "api_version", "=", "0", ")", ":", "return", "(", "struct", ".", "pack", "(", "'>hhih'", ",", "request_key", ",", "# ApiKey", "api_version", ",", "...
Encode the common request envelope
[ "Encode", "the", "common", "request", "envelope" ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/kafkacodec.py#L61-L71
ciena/afkak
afkak/kafkacodec.py
KafkaCodec._encode_message_set
def _encode_message_set(cls, messages, offset=None): """ Encode a MessageSet. Unlike other arrays in the protocol, MessageSets are not length-prefixed. Format:: MessageSet => [Offset MessageSize Message] Offset => int64 MessageSize => int32 """ ...
python
def _encode_message_set(cls, messages, offset=None): """ Encode a MessageSet. Unlike other arrays in the protocol, MessageSets are not length-prefixed. Format:: MessageSet => [Offset MessageSize Message] Offset => int64 MessageSize => int32 """ ...
[ "def", "_encode_message_set", "(", "cls", ",", "messages", ",", "offset", "=", "None", ")", ":", "message_set", "=", "[", "]", "incr", "=", "1", "if", "offset", "is", "None", ":", "incr", "=", "0", "offset", "=", "0", "for", "message", "in", "message...
Encode a MessageSet. Unlike other arrays in the protocol, MessageSets are not length-prefixed. Format:: MessageSet => [Offset MessageSize Message] Offset => int64 MessageSize => int32
[ "Encode", "a", "MessageSet", ".", "Unlike", "other", "arrays", "in", "the", "protocol", "MessageSets", "are", "not", "length", "-", "prefixed", ".", "Format", "::" ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/kafkacodec.py#L74-L93
ciena/afkak
afkak/kafkacodec.py
KafkaCodec._encode_message
def _encode_message(cls, message): """ Encode a single message. The magic number of a message is a format version number. The only supported magic number right now is zero. Format:: Message => Crc MagicByte Attributes Key Value Crc => int32 Mag...
python
def _encode_message(cls, message): """ Encode a single message. The magic number of a message is a format version number. The only supported magic number right now is zero. Format:: Message => Crc MagicByte Attributes Key Value Crc => int32 Mag...
[ "def", "_encode_message", "(", "cls", ",", "message", ")", ":", "if", "message", ".", "magic", "==", "0", ":", "msg", "=", "struct", ".", "pack", "(", "'>BB'", ",", "message", ".", "magic", ",", "message", ".", "attributes", ")", "msg", "+=", "write_...
Encode a single message. The magic number of a message is a format version number. The only supported magic number right now is zero. Format:: Message => Crc MagicByte Attributes Key Value Crc => int32 MagicByte => int8 Attributes => int8 ...
[ "Encode", "a", "single", "message", "." ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/kafkacodec.py#L96-L118
ciena/afkak
afkak/kafkacodec.py
KafkaCodec.encode_produce_request
def encode_produce_request(cls, client_id, correlation_id, payloads=None, acks=1, timeout=DEFAULT_REPLICAS_ACK_TIMEOUT_MSECS): """ Encode some ProduceRequest structs :param bytes client_id: :param int correlation_id: ...
python
def encode_produce_request(cls, client_id, correlation_id, payloads=None, acks=1, timeout=DEFAULT_REPLICAS_ACK_TIMEOUT_MSECS): """ Encode some ProduceRequest structs :param bytes client_id: :param int correlation_id: ...
[ "def", "encode_produce_request", "(", "cls", ",", "client_id", ",", "correlation_id", ",", "payloads", "=", "None", ",", "acks", "=", "1", ",", "timeout", "=", "DEFAULT_REPLICAS_ACK_TIMEOUT_MSECS", ")", ":", "if", "not", "isinstance", "(", "client_id", ",", "b...
Encode some ProduceRequest structs :param bytes client_id: :param int correlation_id: :param list payloads: list of ProduceRequest :param int acks: How "acky" you want the request to be: 0: immediate response 1: written to disk by the leader ...
[ "Encode", "some", "ProduceRequest", "structs" ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/kafkacodec.py#L206-L247
ciena/afkak
afkak/kafkacodec.py
KafkaCodec.decode_produce_response
def decode_produce_response(cls, data): """ Decode bytes to a ProduceResponse :param bytes data: bytes to decode :returns: iterable of `afkak.common.ProduceResponse` """ ((correlation_id, num_topics), cur) = relative_unpack('>ii', data, 0) for _i in range(num_to...
python
def decode_produce_response(cls, data): """ Decode bytes to a ProduceResponse :param bytes data: bytes to decode :returns: iterable of `afkak.common.ProduceResponse` """ ((correlation_id, num_topics), cur) = relative_unpack('>ii', data, 0) for _i in range(num_to...
[ "def", "decode_produce_response", "(", "cls", ",", "data", ")", ":", "(", "(", "correlation_id", ",", "num_topics", ")", ",", "cur", ")", "=", "relative_unpack", "(", "'>ii'", ",", "data", ",", "0", ")", "for", "_i", "in", "range", "(", "num_topics", "...
Decode bytes to a ProduceResponse :param bytes data: bytes to decode :returns: iterable of `afkak.common.ProduceResponse`
[ "Decode", "bytes", "to", "a", "ProduceResponse" ]
train
https://github.com/ciena/afkak/blob/6f5e05ba6f135ea3c29cdb80efda009f7845569a/afkak/kafkacodec.py#L250-L265