partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
PayPalInterface._check_required
Checks kwargs for the values specified in 'requires', which is a tuple of strings. These strings are the NVP names of the required values.
paypal/interface.py
def _check_required(self, requires, **kwargs): """ Checks kwargs for the values specified in 'requires', which is a tuple of strings. These strings are the NVP names of the required values. """ for req in requires: # PayPal api is never mixed-case. if req....
def _check_required(self, requires, **kwargs): """ Checks kwargs for the values specified in 'requires', which is a tuple of strings. These strings are the NVP names of the required values. """ for req in requires: # PayPal api is never mixed-case. if req....
[ "Checks", "kwargs", "for", "the", "values", "specified", "in", "requires", "which", "is", "a", "tuple", "of", "strings", ".", "These", "strings", "are", "the", "NVP", "names", "of", "the", "required", "values", "." ]
gtaylor/paypal-python
python
https://github.com/gtaylor/paypal-python/blob/aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1/paypal/interface.py#L74-L82
[ "def", "_check_required", "(", "self", ",", "requires", ",", "*", "*", "kwargs", ")", ":", "for", "req", "in", "requires", ":", "# PayPal api is never mixed-case.", "if", "req", ".", "lower", "(", ")", "not", "in", "kwargs", "and", "req", ".", "upper", "...
aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1
train
PayPalInterface._call
Wrapper method for executing all API commands over HTTP. This method is further used to implement wrapper methods listed here: https://www.x.com/docs/DOC-1374 ``method`` must be a supported NVP method listed at the above address. ``kwargs`` the actual call parameters
paypal/interface.py
def _call(self, method, **kwargs): """ Wrapper method for executing all API commands over HTTP. This method is further used to implement wrapper methods listed here: https://www.x.com/docs/DOC-1374 ``method`` must be a supported NVP method listed at the above address. `...
def _call(self, method, **kwargs): """ Wrapper method for executing all API commands over HTTP. This method is further used to implement wrapper methods listed here: https://www.x.com/docs/DOC-1374 ``method`` must be a supported NVP method listed at the above address. `...
[ "Wrapper", "method", "for", "executing", "all", "API", "commands", "over", "HTTP", ".", "This", "method", "is", "further", "used", "to", "implement", "wrapper", "methods", "listed", "here", ":" ]
gtaylor/paypal-python
python
https://github.com/gtaylor/paypal-python/blob/aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1/paypal/interface.py#L95-L120
[ "def", "_call", "(", "self", ",", "method", ",", "*", "*", "kwargs", ")", ":", "post_params", "=", "self", ".", "_get_call_params", "(", "method", ",", "*", "*", "kwargs", ")", "payload", "=", "post_params", "[", "'data'", "]", "api_endpoint", "=", "po...
aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1
train
PayPalInterface._get_call_params
Returns the prepared call parameters. Mind, these will be keyword arguments to ``requests.post``. ``method`` the NVP method ``kwargs`` the actual call parameters
paypal/interface.py
def _get_call_params(self, method, **kwargs): """ Returns the prepared call parameters. Mind, these will be keyword arguments to ``requests.post``. ``method`` the NVP method ``kwargs`` the actual call parameters """ payload = {'METHOD': method, ...
def _get_call_params(self, method, **kwargs): """ Returns the prepared call parameters. Mind, these will be keyword arguments to ``requests.post``. ``method`` the NVP method ``kwargs`` the actual call parameters """ payload = {'METHOD': method, ...
[ "Returns", "the", "prepared", "call", "parameters", ".", "Mind", "these", "will", "be", "keyword", "arguments", "to", "requests", ".", "post", "." ]
gtaylor/paypal-python
python
https://github.com/gtaylor/paypal-python/blob/aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1/paypal/interface.py#L122-L161
[ "def", "_get_call_params", "(", "self", ",", "method", ",", "*", "*", "kwargs", ")", ":", "payload", "=", "{", "'METHOD'", ":", "method", ",", "'VERSION'", ":", "self", ".", "config", ".", "API_VERSION", "}", "certificate", "=", "None", "if", "self", "...
aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1
train
PayPalInterface.address_verify
Shortcut for the AddressVerify method. ``email``:: Email address of a PayPal member to verify. Maximum string length: 255 single-byte characters Input mask: ?@?.?? ``street``:: First line of the billing or shipping postal address to verify. T...
paypal/interface.py
def address_verify(self, email, street, zip): """Shortcut for the AddressVerify method. ``email``:: Email address of a PayPal member to verify. Maximum string length: 255 single-byte characters Input mask: ?@?.?? ``street``:: First line of the bil...
def address_verify(self, email, street, zip): """Shortcut for the AddressVerify method. ``email``:: Email address of a PayPal member to verify. Maximum string length: 255 single-byte characters Input mask: ?@?.?? ``street``:: First line of the bil...
[ "Shortcut", "for", "the", "AddressVerify", "method", "." ]
gtaylor/paypal-python
python
https://github.com/gtaylor/paypal-python/blob/aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1/paypal/interface.py#L163-L190
[ "def", "address_verify", "(", "self", ",", "email", ",", "street", ",", "zip", ")", ":", "args", "=", "self", ".", "_sanitize_locals", "(", "locals", "(", ")", ")", "return", "self", ".", "_call", "(", "'AddressVerify'", ",", "*", "*", "args", ")" ]
aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1
train
PayPalInterface.do_authorization
Shortcut for the DoAuthorization method. Use the TRANSACTIONID from DoExpressCheckoutPayment for the ``transactionid``. The latest version of the API does not support the creation of an Order from `DoDirectPayment`. The `amt` should be the same as passed to `DoExpressCheckoutPayment`. ...
paypal/interface.py
def do_authorization(self, transactionid, amt): """Shortcut for the DoAuthorization method. Use the TRANSACTIONID from DoExpressCheckoutPayment for the ``transactionid``. The latest version of the API does not support the creation of an Order from `DoDirectPayment`. The `amt` s...
def do_authorization(self, transactionid, amt): """Shortcut for the DoAuthorization method. Use the TRANSACTIONID from DoExpressCheckoutPayment for the ``transactionid``. The latest version of the API does not support the creation of an Order from `DoDirectPayment`. The `amt` s...
[ "Shortcut", "for", "the", "DoAuthorization", "method", "." ]
gtaylor/paypal-python
python
https://github.com/gtaylor/paypal-python/blob/aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1/paypal/interface.py#L228-L251
[ "def", "do_authorization", "(", "self", ",", "transactionid", ",", "amt", ")", ":", "args", "=", "self", ".", "_sanitize_locals", "(", "locals", "(", ")", ")", "return", "self", ".", "_call", "(", "'DoAuthorization'", ",", "*", "*", "args", ")" ]
aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1
train
PayPalInterface.do_capture
Shortcut for the DoCapture method. Use the TRANSACTIONID from DoAuthorization, DoDirectPayment or DoExpressCheckoutPayment for the ``authorizationid``. The `amt` should be the same as the authorized transaction.
paypal/interface.py
def do_capture(self, authorizationid, amt, completetype='Complete', **kwargs): """Shortcut for the DoCapture method. Use the TRANSACTIONID from DoAuthorization, DoDirectPayment or DoExpressCheckoutPayment for the ``authorizationid``. The `amt` should be the same as t...
def do_capture(self, authorizationid, amt, completetype='Complete', **kwargs): """Shortcut for the DoCapture method. Use the TRANSACTIONID from DoAuthorization, DoDirectPayment or DoExpressCheckoutPayment for the ``authorizationid``. The `amt` should be the same as t...
[ "Shortcut", "for", "the", "DoCapture", "method", "." ]
gtaylor/paypal-python
python
https://github.com/gtaylor/paypal-python/blob/aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1/paypal/interface.py#L253-L263
[ "def", "do_capture", "(", "self", ",", "authorizationid", ",", "amt", ",", "completetype", "=", "'Complete'", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "self", ".", "_sanitize_locals", "(", "locals", "(", ")", ")", ")", "return", ...
aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1
train
PayPalInterface.do_direct_payment
Shortcut for the DoDirectPayment method. ``paymentaction`` could be 'Authorization' or 'Sale' To issue a Sale immediately:: charge = { 'amt': '10.00', 'creditcardtype': 'Visa', 'acct': '4812177017895760', 'expdate': '012010',...
paypal/interface.py
def do_direct_payment(self, paymentaction="Sale", **kwargs): """Shortcut for the DoDirectPayment method. ``paymentaction`` could be 'Authorization' or 'Sale' To issue a Sale immediately:: charge = { 'amt': '10.00', 'creditcardtype': 'Visa', ...
def do_direct_payment(self, paymentaction="Sale", **kwargs): """Shortcut for the DoDirectPayment method. ``paymentaction`` could be 'Authorization' or 'Sale' To issue a Sale immediately:: charge = { 'amt': '10.00', 'creditcardtype': 'Visa', ...
[ "Shortcut", "for", "the", "DoDirectPayment", "method", "." ]
gtaylor/paypal-python
python
https://github.com/gtaylor/paypal-python/blob/aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1/paypal/interface.py#L265-L302
[ "def", "do_direct_payment", "(", "self", ",", "paymentaction", "=", "\"Sale\"", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "self", ".", "_sanitize_locals", "(", "locals", "(", ")", ")", ")", "return", "self", ".", "_call", "(", "'...
aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1
train
PayPalInterface.transaction_search
Shortcut for the TransactionSearch method. Returns a PayPalResponseList object, which merges the L_ syntax list to a list of dictionaries with properly named keys. Note that the API will limit returned transactions to 100. Required Kwargs --------------- * STARTDATE ...
paypal/interface.py
def transaction_search(self, **kwargs): """Shortcut for the TransactionSearch method. Returns a PayPalResponseList object, which merges the L_ syntax list to a list of dictionaries with properly named keys. Note that the API will limit returned transactions to 100. Required Kwa...
def transaction_search(self, **kwargs): """Shortcut for the TransactionSearch method. Returns a PayPalResponseList object, which merges the L_ syntax list to a list of dictionaries with properly named keys. Note that the API will limit returned transactions to 100. Required Kwa...
[ "Shortcut", "for", "the", "TransactionSearch", "method", ".", "Returns", "a", "PayPalResponseList", "object", "which", "merges", "the", "L_", "syntax", "list", "to", "a", "list", "of", "dictionaries", "with", "properly", "named", "keys", "." ]
gtaylor/paypal-python
python
https://github.com/gtaylor/paypal-python/blob/aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1/paypal/interface.py#L338-L355
[ "def", "transaction_search", "(", "self", ",", "*", "*", "kwargs", ")", ":", "plain", "=", "self", ".", "_call", "(", "'TransactionSearch'", ",", "*", "*", "kwargs", ")", "return", "PayPalResponseList", "(", "plain", ".", "raw", ",", "self", ".", "config...
aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1
train
PayPalInterface.refund_transaction
Shortcut for RefundTransaction method. Note new API supports passing a PayerID instead of a transaction id, exactly one must be provided. Optional: INVOICEID REFUNDTYPE AMT CURRENCYCODE NOTE RETRY...
paypal/interface.py
def refund_transaction(self, transactionid=None, payerid=None, **kwargs): """Shortcut for RefundTransaction method. Note new API supports passing a PayerID instead of a transaction id, exactly one must be provided. Optional: INVOICEID REFUNDTYPE ...
def refund_transaction(self, transactionid=None, payerid=None, **kwargs): """Shortcut for RefundTransaction method. Note new API supports passing a PayerID instead of a transaction id, exactly one must be provided. Optional: INVOICEID REFUNDTYPE ...
[ "Shortcut", "for", "RefundTransaction", "method", ".", "Note", "new", "API", "supports", "passing", "a", "PayerID", "instead", "of", "a", "transaction", "id", "exactly", "one", "must", "be", "provided", "." ]
gtaylor/paypal-python
python
https://github.com/gtaylor/paypal-python/blob/aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1/paypal/interface.py#L375-L412
[ "def", "refund_transaction", "(", "self", ",", "transactionid", "=", "None", ",", "payerid", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# This line seems like a complete waste of time... kwargs should not", "# be populated", "if", "(", "transactionid", "is", "No...
aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1
train
PayPalInterface.generate_express_checkout_redirect_url
Returns the URL to redirect the user to for the Express checkout. Express Checkouts must be verified by the customer by redirecting them to the PayPal website. Use the token returned in the response from :meth:`set_express_checkout` with this function to figure out where to redirect the...
paypal/interface.py
def generate_express_checkout_redirect_url(self, token, useraction=None): """Returns the URL to redirect the user to for the Express checkout. Express Checkouts must be verified by the customer by redirecting them to the PayPal website. Use the token returned in the response from :meth:...
def generate_express_checkout_redirect_url(self, token, useraction=None): """Returns the URL to redirect the user to for the Express checkout. Express Checkouts must be verified by the customer by redirecting them to the PayPal website. Use the token returned in the response from :meth:...
[ "Returns", "the", "URL", "to", "redirect", "the", "user", "to", "for", "the", "Express", "checkout", "." ]
gtaylor/paypal-python
python
https://github.com/gtaylor/paypal-python/blob/aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1/paypal/interface.py#L430-L454
[ "def", "generate_express_checkout_redirect_url", "(", "self", ",", "token", ",", "useraction", "=", "None", ")", ":", "url_vars", "=", "(", "self", ".", "config", ".", "PAYPAL_URL_BASE", ",", "token", ")", "url", "=", "\"%s?cmd=_express-checkout&token=%s\"", "%", ...
aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1
train
PayPalInterface.generate_cart_upload_redirect_url
https://www.sandbox.paypal.com/webscr ?cmd=_cart &upload=1
paypal/interface.py
def generate_cart_upload_redirect_url(self, **kwargs): """https://www.sandbox.paypal.com/webscr ?cmd=_cart &upload=1 """ required_vals = ('business', 'item_name_1', 'amount_1', 'quantity_1') self._check_required(required_vals, **kwargs) url = "%s?cmd=_cart...
def generate_cart_upload_redirect_url(self, **kwargs): """https://www.sandbox.paypal.com/webscr ?cmd=_cart &upload=1 """ required_vals = ('business', 'item_name_1', 'amount_1', 'quantity_1') self._check_required(required_vals, **kwargs) url = "%s?cmd=_cart...
[ "https", ":", "//", "www", ".", "sandbox", ".", "paypal", ".", "com", "/", "webscr", "?cmd", "=", "_cart", "&upload", "=", "1" ]
gtaylor/paypal-python
python
https://github.com/gtaylor/paypal-python/blob/aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1/paypal/interface.py#L456-L466
[ "def", "generate_cart_upload_redirect_url", "(", "self", ",", "*", "*", "kwargs", ")", ":", "required_vals", "=", "(", "'business'", ",", "'item_name_1'", ",", "'amount_1'", ",", "'quantity_1'", ")", "self", ".", "_check_required", "(", "required_vals", ",", "*"...
aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1
train
PayPalInterface.get_recurring_payments_profile_details
Shortcut for the GetRecurringPaymentsProfile method. This returns details for a recurring payment plan. The ``profileid`` is a value included in the response retrieved by the function ``create_recurring_payments_profile``. The profile details include the data provided when the profile w...
paypal/interface.py
def get_recurring_payments_profile_details(self, profileid): """Shortcut for the GetRecurringPaymentsProfile method. This returns details for a recurring payment plan. The ``profileid`` is a value included in the response retrieved by the function ``create_recurring_payments_profile``. ...
def get_recurring_payments_profile_details(self, profileid): """Shortcut for the GetRecurringPaymentsProfile method. This returns details for a recurring payment plan. The ``profileid`` is a value included in the response retrieved by the function ``create_recurring_payments_profile``. ...
[ "Shortcut", "for", "the", "GetRecurringPaymentsProfile", "method", "." ]
gtaylor/paypal-python
python
https://github.com/gtaylor/paypal-python/blob/aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1/paypal/interface.py#L468-L487
[ "def", "get_recurring_payments_profile_details", "(", "self", ",", "profileid", ")", ":", "args", "=", "self", ".", "_sanitize_locals", "(", "locals", "(", ")", ")", "return", "self", ".", "_call", "(", "'GetRecurringPaymentsProfileDetails'", ",", "*", "*", "arg...
aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1
train
PayPalInterface.manage_recurring_payments_profile_status
Shortcut to the ManageRecurringPaymentsProfileStatus method. ``profileid`` is the same profile id used for getting profile details. ``action`` should be either 'Cancel', 'Suspend', or 'Reactivate'. ``note`` is optional and is visible to the user. It contains the reason for the chang...
paypal/interface.py
def manage_recurring_payments_profile_status(self, profileid, action, note=None): """Shortcut to the ManageRecurringPaymentsProfileStatus method. ``profileid`` is the same profile id used for getting profile details. ``action`` should be either '...
def manage_recurring_payments_profile_status(self, profileid, action, note=None): """Shortcut to the ManageRecurringPaymentsProfileStatus method. ``profileid`` is the same profile id used for getting profile details. ``action`` should be either '...
[ "Shortcut", "to", "the", "ManageRecurringPaymentsProfileStatus", "method", "." ]
gtaylor/paypal-python
python
https://github.com/gtaylor/paypal-python/blob/aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1/paypal/interface.py#L489-L501
[ "def", "manage_recurring_payments_profile_status", "(", "self", ",", "profileid", ",", "action", ",", "note", "=", "None", ")", ":", "args", "=", "self", ".", "_sanitize_locals", "(", "locals", "(", ")", ")", "if", "not", "note", ":", "del", "args", "[", ...
aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1
train
PayPalInterface.update_recurring_payments_profile
Shortcut to the UpdateRecurringPaymentsProfile method. ``profileid`` is the same profile id used for getting profile details. The keyed arguments are data in the payment profile which you wish to change. The profileid does not change. Anything else will take the new value. Most of, tho...
paypal/interface.py
def update_recurring_payments_profile(self, profileid, **kwargs): """Shortcut to the UpdateRecurringPaymentsProfile method. ``profileid`` is the same profile id used for getting profile details. The keyed arguments are data in the payment profile which you wish to change. The profileid...
def update_recurring_payments_profile(self, profileid, **kwargs): """Shortcut to the UpdateRecurringPaymentsProfile method. ``profileid`` is the same profile id used for getting profile details. The keyed arguments are data in the payment profile which you wish to change. The profileid...
[ "Shortcut", "to", "the", "UpdateRecurringPaymentsProfile", "method", "." ]
gtaylor/paypal-python
python
https://github.com/gtaylor/paypal-python/blob/aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1/paypal/interface.py#L503-L516
[ "def", "update_recurring_payments_profile", "(", "self", ",", "profileid", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "self", ".", "_sanitize_locals", "(", "locals", "(", ")", ")", ")", "return", "self", ".", "_call", "(", "'UpdateRec...
aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1
train
PayPalInterface.bm_create_button
Shortcut to the BMCreateButton method. See the docs for details on arguments: https://cms.paypal.com/mx/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_BMCreateButton The L_BUTTONVARn fields are especially important, so make sure to read those and act accordingly. See...
paypal/interface.py
def bm_create_button(self, **kwargs): """Shortcut to the BMCreateButton method. See the docs for details on arguments: https://cms.paypal.com/mx/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_BMCreateButton The L_BUTTONVARn fields are especially important, so make su...
def bm_create_button(self, **kwargs): """Shortcut to the BMCreateButton method. See the docs for details on arguments: https://cms.paypal.com/mx/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_nvp_BMCreateButton The L_BUTTONVARn fields are especially important, so make su...
[ "Shortcut", "to", "the", "BMCreateButton", "method", "." ]
gtaylor/paypal-python
python
https://github.com/gtaylor/paypal-python/blob/aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1/paypal/interface.py#L518-L528
[ "def", "bm_create_button", "(", "self", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "update", "(", "self", ".", "_sanitize_locals", "(", "locals", "(", ")", ")", ")", "return", "self", ".", "_call", "(", "'BMCreateButton'", ",", "*", "*", "kwargs...
aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1
train
PayPalResponse.success
Checks for the presence of errors in the response. Returns ``True`` if all is well, ``False`` otherwise. :rtype: bool :returns ``True`` if PayPal says our query was successful.
paypal/response.py
def success(self): """ Checks for the presence of errors in the response. Returns ``True`` if all is well, ``False`` otherwise. :rtype: bool :returns ``True`` if PayPal says our query was successful. """ return self.ack.upper() in (self.config.ACK_SUCCESS, ...
def success(self): """ Checks for the presence of errors in the response. Returns ``True`` if all is well, ``False`` otherwise. :rtype: bool :returns ``True`` if PayPal says our query was successful. """ return self.ack.upper() in (self.config.ACK_SUCCESS, ...
[ "Checks", "for", "the", "presence", "of", "errors", "in", "the", "response", ".", "Returns", "True", "if", "all", "is", "well", "False", "otherwise", "." ]
gtaylor/paypal-python
python
https://github.com/gtaylor/paypal-python/blob/aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1/paypal/response.py#L109-L118
[ "def", "success", "(", "self", ")", ":", "return", "self", ".", "ack", ".", "upper", "(", ")", "in", "(", "self", ".", "config", ".", "ACK_SUCCESS", ",", "self", ".", "config", ".", "ACK_SUCCESS_WITH_WARNING", ")" ]
aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1
train
is_valid_country_abbrev
Given a country code abbreviation, check to see if it matches the country table. abbrev: (str) Country code to evaluate. case_sensitive: (bool) When True, enforce case sensitivity. Returns True if valid, False if not.
paypal/countries.py
def is_valid_country_abbrev(abbrev, case_sensitive=False): """ Given a country code abbreviation, check to see if it matches the country table. abbrev: (str) Country code to evaluate. case_sensitive: (bool) When True, enforce case sensitivity. Returns True if valid, False if not. """ i...
def is_valid_country_abbrev(abbrev, case_sensitive=False): """ Given a country code abbreviation, check to see if it matches the country table. abbrev: (str) Country code to evaluate. case_sensitive: (bool) When True, enforce case sensitivity. Returns True if valid, False if not. """ i...
[ "Given", "a", "country", "code", "abbreviation", "check", "to", "see", "if", "it", "matches", "the", "country", "table", "." ]
gtaylor/paypal-python
python
https://github.com/gtaylor/paypal-python/blob/aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1/paypal/countries.py#L254-L273
[ "def", "is_valid_country_abbrev", "(", "abbrev", ",", "case_sensitive", "=", "False", ")", ":", "if", "case_sensitive", ":", "country_code", "=", "abbrev", "else", ":", "country_code", "=", "abbrev", ".", "upper", "(", ")", "for", "code", ",", "full_name", "...
aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1
train
get_name_from_abbrev
Given a country code abbreviation, get the full name from the table. abbrev: (str) Country code to retrieve the full name of. case_sensitive: (bool) When True, enforce case sensitivity.
paypal/countries.py
def get_name_from_abbrev(abbrev, case_sensitive=False): """ Given a country code abbreviation, get the full name from the table. abbrev: (str) Country code to retrieve the full name of. case_sensitive: (bool) When True, enforce case sensitivity. """ if case_sensitive: country_code = abb...
def get_name_from_abbrev(abbrev, case_sensitive=False): """ Given a country code abbreviation, get the full name from the table. abbrev: (str) Country code to retrieve the full name of. case_sensitive: (bool) When True, enforce case sensitivity. """ if case_sensitive: country_code = abb...
[ "Given", "a", "country", "code", "abbreviation", "get", "the", "full", "name", "from", "the", "table", "." ]
gtaylor/paypal-python
python
https://github.com/gtaylor/paypal-python/blob/aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1/paypal/countries.py#L276-L292
[ "def", "get_name_from_abbrev", "(", "abbrev", ",", "case_sensitive", "=", "False", ")", ":", "if", "case_sensitive", ":", "country_code", "=", "abbrev", "else", ":", "country_code", "=", "abbrev", ".", "upper", "(", ")", "for", "code", ",", "full_name", "in"...
aa7a987ea9e9b7f37bcd8a8b54a440aad6c871b1
train
SchemaMeta.get_declared_fields
Updates declared fields with fields converted from the Mongoengine model passed as the `model` class Meta option.
marshmallow_mongoengine/schema.py
def get_declared_fields(mcs, klass, *args, **kwargs): """Updates declared fields with fields converted from the Mongoengine model passed as the `model` class Meta option. """ declared_fields = kwargs.get('dict_class', dict)() # Generate the fields provided through inheritance ...
def get_declared_fields(mcs, klass, *args, **kwargs): """Updates declared fields with fields converted from the Mongoengine model passed as the `model` class Meta option. """ declared_fields = kwargs.get('dict_class', dict)() # Generate the fields provided through inheritance ...
[ "Updates", "declared", "fields", "with", "fields", "converted", "from", "the", "Mongoengine", "model", "passed", "as", "the", "model", "class", "Meta", "option", "." ]
touilleMan/marshmallow-mongoengine
python
https://github.com/touilleMan/marshmallow-mongoengine/blob/21223700ea1f1d0209c967761e5c22635ee721e7/marshmallow_mongoengine/schema.py#L49-L88
[ "def", "get_declared_fields", "(", "mcs", ",", "klass", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "declared_fields", "=", "kwargs", ".", "get", "(", "'dict_class'", ",", "dict", ")", "(", ")", "# Generate the fields provided through inheritance", "o...
21223700ea1f1d0209c967761e5c22635ee721e7
train
ModelSchema.update
Helper function to update an already existing document instead of creating a new one. :param obj: Mongoengine Document to update :param data: incomming payload to deserialize :return: an :class UnmarshallResult: Example: :: from marshmallow_mongoengine import ModelSchema from mymod...
marshmallow_mongoengine/schema.py
def update(self, obj, data): """Helper function to update an already existing document instead of creating a new one. :param obj: Mongoengine Document to update :param data: incomming payload to deserialize :return: an :class UnmarshallResult: Example: :: from marshmallow_mongoengi...
def update(self, obj, data): """Helper function to update an already existing document instead of creating a new one. :param obj: Mongoengine Document to update :param data: incomming payload to deserialize :return: an :class UnmarshallResult: Example: :: from marshmallow_mongoengi...
[ "Helper", "function", "to", "update", "an", "already", "existing", "document", "instead", "of", "creating", "a", "new", "one", ".", ":", "param", "obj", ":", "Mongoengine", "Document", "to", "update", ":", "param", "data", ":", "incomming", "payload", "to", ...
touilleMan/marshmallow-mongoengine
python
https://github.com/touilleMan/marshmallow-mongoengine/blob/21223700ea1f1d0209c967761e5c22635ee721e7/marshmallow_mongoengine/schema.py#L120-L160
[ "def", "update", "(", "self", ",", "obj", ",", "data", ")", ":", "# TODO: find a cleaner way to skip required validation on update", "required_fields", "=", "[", "k", "for", "k", ",", "f", "in", "self", ".", "fields", ".", "items", "(", ")", "if", "f", ".", ...
21223700ea1f1d0209c967761e5c22635ee721e7
train
register_field
Bind a marshmallow field to it corresponding mongoengine field :param mongo_field_cls: Mongoengine Field :param marshmallow_field_cls: Marshmallow Field :param available_params: List of :class marshmallow_mongoengine.cnoversion.params.MetaParam: instances to import the mongoengine field config to ma...
marshmallow_mongoengine/conversion/fields.py
def register_field(mongo_field_cls, marshmallow_field_cls, available_params=()): """ Bind a marshmallow field to it corresponding mongoengine field :param mongo_field_cls: Mongoengine Field :param marshmallow_field_cls: Marshmallow Field :param available_params: List of :class mar...
def register_field(mongo_field_cls, marshmallow_field_cls, available_params=()): """ Bind a marshmallow field to it corresponding mongoengine field :param mongo_field_cls: Mongoengine Field :param marshmallow_field_cls: Marshmallow Field :param available_params: List of :class mar...
[ "Bind", "a", "marshmallow", "field", "to", "it", "corresponding", "mongoengine", "field", ":", "param", "mongo_field_cls", ":", "Mongoengine", "Field", ":", "param", "marshmallow_field_cls", ":", "Marshmallow", "Field", ":", "param", "available_params", ":", "List",...
touilleMan/marshmallow-mongoengine
python
https://github.com/touilleMan/marshmallow-mongoengine/blob/21223700ea1f1d0209c967761e5c22635ee721e7/marshmallow_mongoengine/conversion/fields.py#L143-L155
[ "def", "register_field", "(", "mongo_field_cls", ",", "marshmallow_field_cls", ",", "available_params", "=", "(", ")", ")", ":", "class", "Builder", "(", "MetaFieldBuilder", ")", ":", "AVAILABLE_PARAMS", "=", "available_params", "MARSHMALLOW_FIELD_CLS", "=", "marshmal...
21223700ea1f1d0209c967761e5c22635ee721e7
train
MetaFieldBuilder.build_marshmallow_field
:return: The Marshmallow Field instanciated and configured
marshmallow_mongoengine/conversion/fields.py
def build_marshmallow_field(self, **kwargs): """ :return: The Marshmallow Field instanciated and configured """ field_kwargs = None for param in self.params: field_kwargs = param.apply(field_kwargs) field_kwargs.update(kwargs) return self.marshmallow_f...
def build_marshmallow_field(self, **kwargs): """ :return: The Marshmallow Field instanciated and configured """ field_kwargs = None for param in self.params: field_kwargs = param.apply(field_kwargs) field_kwargs.update(kwargs) return self.marshmallow_f...
[ ":", "return", ":", "The", "Marshmallow", "Field", "instanciated", "and", "configured" ]
touilleMan/marshmallow-mongoengine
python
https://github.com/touilleMan/marshmallow-mongoengine/blob/21223700ea1f1d0209c967761e5c22635ee721e7/marshmallow_mongoengine/conversion/fields.py#L25-L33
[ "def", "build_marshmallow_field", "(", "self", ",", "*", "*", "kwargs", ")", ":", "field_kwargs", "=", "None", "for", "param", "in", "self", ".", "params", ":", "field_kwargs", "=", "param", ".", "apply", "(", "field_kwargs", ")", "field_kwargs", ".", "upd...
21223700ea1f1d0209c967761e5c22635ee721e7
train
Nyamuk.loop
Main loop.
nyamuk/nyamuk.py
def loop(self, timeout = 1): """Main loop.""" rlist = [self.sock] wlist = [] if len(self.out_packet) > 0: wlist.append(self.sock) to_read, to_write, _ = select.select(rlist, wlist, [], timeout) if len(to_read) > 0: ret, _ = self.loop_read...
def loop(self, timeout = 1): """Main loop.""" rlist = [self.sock] wlist = [] if len(self.out_packet) > 0: wlist.append(self.sock) to_read, to_write, _ = select.select(rlist, wlist, [], timeout) if len(to_read) > 0: ret, _ = self.loop_read...
[ "Main", "loop", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L49-L70
[ "def", "loop", "(", "self", ",", "timeout", "=", "1", ")", ":", "rlist", "=", "[", "self", ".", "sock", "]", "wlist", "=", "[", "]", "if", "len", "(", "self", ".", "out_packet", ")", ">", "0", ":", "wlist", ".", "append", "(", "self", ".", "s...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.loop_misc
Misc loop.
nyamuk/nyamuk.py
def loop_misc(self): """Misc loop.""" self.check_keepalive() if self.last_retry_check + 1 < time.time(): pass return NC.ERR_SUCCESS
def loop_misc(self): """Misc loop.""" self.check_keepalive() if self.last_retry_check + 1 < time.time(): pass return NC.ERR_SUCCESS
[ "Misc", "loop", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L82-L87
[ "def", "loop_misc", "(", "self", ")", ":", "self", ".", "check_keepalive", "(", ")", "if", "self", ".", "last_retry_check", "+", "1", "<", "time", ".", "time", "(", ")", ":", "pass", "return", "NC", ".", "ERR_SUCCESS" ]
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.check_keepalive
Send keepalive/PING if necessary.
nyamuk/nyamuk.py
def check_keepalive(self): """Send keepalive/PING if necessary.""" if self.sock != NC.INVALID_SOCKET and time.time() - self.last_msg_out >= self.keep_alive: if self.state == NC.CS_CONNECTED: self.send_pingreq() else: self.socket_close()
def check_keepalive(self): """Send keepalive/PING if necessary.""" if self.sock != NC.INVALID_SOCKET and time.time() - self.last_msg_out >= self.keep_alive: if self.state == NC.CS_CONNECTED: self.send_pingreq() else: self.socket_close()
[ "Send", "keepalive", "/", "PING", "if", "necessary", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L89-L95
[ "def", "check_keepalive", "(", "self", ")", ":", "if", "self", ".", "sock", "!=", "NC", ".", "INVALID_SOCKET", "and", "time", ".", "time", "(", ")", "-", "self", ".", "last_msg_out", ">=", "self", ".", "keep_alive", ":", "if", "self", ".", "state", "...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.packet_handle
Incoming packet handler dispatcher.
nyamuk/nyamuk.py
def packet_handle(self): """Incoming packet handler dispatcher.""" cmd = self.in_packet.command & 0xF0 if cmd == NC.CMD_CONNACK: return self.handle_connack() elif cmd == NC.CMD_PINGRESP: return self.handle_pingresp() elif cmd == NC.CMD_PUBLISH: ...
def packet_handle(self): """Incoming packet handler dispatcher.""" cmd = self.in_packet.command & 0xF0 if cmd == NC.CMD_CONNACK: return self.handle_connack() elif cmd == NC.CMD_PINGRESP: return self.handle_pingresp() elif cmd == NC.CMD_PUBLISH: ...
[ "Incoming", "packet", "handler", "dispatcher", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L97-L126
[ "def", "packet_handle", "(", "self", ")", ":", "cmd", "=", "self", ".", "in_packet", ".", "command", "&", "0xF0", "if", "cmd", "==", "NC", ".", "CMD_CONNACK", ":", "return", "self", ".", "handle_connack", "(", ")", "elif", "cmd", "==", "NC", ".", "CM...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.connect
Connect to server.
nyamuk/nyamuk.py
def connect(self, version = 3, clean_session = 1, will = None): """Connect to server.""" self.clean_session = clean_session self.will = None if will is not None: self.will = NyamukMsg( topic = will['topic'], # unicode text nee...
def connect(self, version = 3, clean_session = 1, will = None): """Connect to server.""" self.clean_session = clean_session self.will = None if will is not None: self.will = NyamukMsg( topic = will['topic'], # unicode text nee...
[ "Connect", "to", "server", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L132-L180
[ "def", "connect", "(", "self", ",", "version", "=", "3", ",", "clean_session", "=", "1", ",", "will", "=", "None", ")", ":", "self", ".", "clean_session", "=", "clean_session", "self", ".", "will", "=", "None", "if", "will", "is", "not", "None", ":",...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.disconnect
Disconnect from server.
nyamuk/nyamuk.py
def disconnect(self): """Disconnect from server.""" self.logger.info("DISCONNECT") if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN self.state = NC.CS_DISCONNECTING ret = self.send_disconnect() ret2, bytes_written = self.packet_write() ...
def disconnect(self): """Disconnect from server.""" self.logger.info("DISCONNECT") if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN self.state = NC.CS_DISCONNECTING ret = self.send_disconnect() ret2, bytes_written = self.packet_write() ...
[ "Disconnect", "from", "server", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L182-L193
[ "def", "disconnect", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"DISCONNECT\"", ")", "if", "self", ".", "sock", "==", "NC", ".", "INVALID_SOCKET", ":", "return", "NC", ".", "ERR_NO_CONN", "self", ".", "state", "=", "NC", ".", "...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.subscribe
Subscribe to some topic.
nyamuk/nyamuk.py
def subscribe(self, topic, qos): """Subscribe to some topic.""" if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN self.logger.info("SUBSCRIBE: %s", topic) return self.send_subscribe(False, [(utf8encode(topic), qos)])
def subscribe(self, topic, qos): """Subscribe to some topic.""" if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN self.logger.info("SUBSCRIBE: %s", topic) return self.send_subscribe(False, [(utf8encode(topic), qos)])
[ "Subscribe", "to", "some", "topic", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L195-L201
[ "def", "subscribe", "(", "self", ",", "topic", ",", "qos", ")", ":", "if", "self", ".", "sock", "==", "NC", ".", "INVALID_SOCKET", ":", "return", "NC", ".", "ERR_NO_CONN", "self", ".", "logger", ".", "info", "(", "\"SUBSCRIBE: %s\"", ",", "topic", ")",...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.subscribe_multi
Subscribe to some topics.
nyamuk/nyamuk.py
def subscribe_multi(self, topics): """Subscribe to some topics.""" if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN self.logger.info("SUBSCRIBE: %s", ', '.join([t for (t,q) in topics])) return self.send_subscribe(False, [(utf8encode(topic), qos) for (topic, q...
def subscribe_multi(self, topics): """Subscribe to some topics.""" if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN self.logger.info("SUBSCRIBE: %s", ', '.join([t for (t,q) in topics])) return self.send_subscribe(False, [(utf8encode(topic), qos) for (topic, q...
[ "Subscribe", "to", "some", "topics", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L204-L210
[ "def", "subscribe_multi", "(", "self", ",", "topics", ")", ":", "if", "self", ".", "sock", "==", "NC", ".", "INVALID_SOCKET", ":", "return", "NC", ".", "ERR_NO_CONN", "self", ".", "logger", ".", "info", "(", "\"SUBSCRIBE: %s\"", ",", "', '", ".", "join",...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.unsubscribe
Unsubscribe to some topic.
nyamuk/nyamuk.py
def unsubscribe(self, topic): """Unsubscribe to some topic.""" if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN self.logger.info("UNSUBSCRIBE: %s", topic) return self.send_unsubscribe(False, [utf8encode(topic)])
def unsubscribe(self, topic): """Unsubscribe to some topic.""" if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN self.logger.info("UNSUBSCRIBE: %s", topic) return self.send_unsubscribe(False, [utf8encode(topic)])
[ "Unsubscribe", "to", "some", "topic", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L212-L218
[ "def", "unsubscribe", "(", "self", ",", "topic", ")", ":", "if", "self", ".", "sock", "==", "NC", ".", "INVALID_SOCKET", ":", "return", "NC", ".", "ERR_NO_CONN", "self", ".", "logger", ".", "info", "(", "\"UNSUBSCRIBE: %s\"", ",", "topic", ")", "return",...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.unsubscribe_multi
Unsubscribe to some topics.
nyamuk/nyamuk.py
def unsubscribe_multi(self, topics): """Unsubscribe to some topics.""" if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN self.logger.info("UNSUBSCRIBE: %s", ', '.join(topics)) return self.send_unsubscribe(False, [utf8encode(topic) for topic in topics])
def unsubscribe_multi(self, topics): """Unsubscribe to some topics.""" if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN self.logger.info("UNSUBSCRIBE: %s", ', '.join(topics)) return self.send_unsubscribe(False, [utf8encode(topic) for topic in topics])
[ "Unsubscribe", "to", "some", "topics", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L220-L226
[ "def", "unsubscribe_multi", "(", "self", ",", "topics", ")", ":", "if", "self", ".", "sock", "==", "NC", ".", "INVALID_SOCKET", ":", "return", "NC", ".", "ERR_NO_CONN", "self", ".", "logger", ".", "info", "(", "\"UNSUBSCRIBE: %s\"", ",", "', '", ".", "jo...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.send_subscribe
Send subscribe COMMAND to server.
nyamuk/nyamuk.py
def send_subscribe(self, dup, topics): """Send subscribe COMMAND to server.""" pkt = MqttPkt() pktlen = 2 + sum([2+len(topic)+1 for (topic, qos) in topics]) pkt.command = NC.CMD_SUBSCRIBE | (dup << 3) | (1 << 1) pkt.remaining_length = pktlen ret = pkt.al...
def send_subscribe(self, dup, topics): """Send subscribe COMMAND to server.""" pkt = MqttPkt() pktlen = 2 + sum([2+len(topic)+1 for (topic, qos) in topics]) pkt.command = NC.CMD_SUBSCRIBE | (dup << 3) | (1 << 1) pkt.remaining_length = pktlen ret = pkt.al...
[ "Send", "subscribe", "COMMAND", "to", "server", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L233-L254
[ "def", "send_subscribe", "(", "self", ",", "dup", ",", "topics", ")", ":", "pkt", "=", "MqttPkt", "(", ")", "pktlen", "=", "2", "+", "sum", "(", "[", "2", "+", "len", "(", "topic", ")", "+", "1", "for", "(", "topic", ",", "qos", ")", "in", "t...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.send_unsubscribe
Send unsubscribe COMMAND to server.
nyamuk/nyamuk.py
def send_unsubscribe(self, dup, topics): """Send unsubscribe COMMAND to server.""" pkt = MqttPkt() pktlen = 2 + sum([2+len(topic) for topic in topics]) pkt.command = NC.CMD_UNSUBSCRIBE | (dup << 3) | (1 << 1) pkt.remaining_length = pktlen ret = pkt.alloc...
def send_unsubscribe(self, dup, topics): """Send unsubscribe COMMAND to server.""" pkt = MqttPkt() pktlen = 2 + sum([2+len(topic) for topic in topics]) pkt.command = NC.CMD_UNSUBSCRIBE | (dup << 3) | (1 << 1) pkt.remaining_length = pktlen ret = pkt.alloc...
[ "Send", "unsubscribe", "COMMAND", "to", "server", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L256-L276
[ "def", "send_unsubscribe", "(", "self", ",", "dup", ",", "topics", ")", ":", "pkt", "=", "MqttPkt", "(", ")", "pktlen", "=", "2", "+", "sum", "(", "[", "2", "+", "len", "(", "topic", ")", "for", "topic", "in", "topics", "]", ")", "pkt", ".", "c...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.publish
Publish some payload to server.
nyamuk/nyamuk.py
def publish(self, topic, payload = None, qos = 0, retain = False): """Publish some payload to server.""" #print "PUBLISHING (",topic,"): ", payload payloadlen = len(payload) if topic is None or qos < 0 or qos > 2: print "PUBLISH:err inval" return NC.ERR_INVAL ...
def publish(self, topic, payload = None, qos = 0, retain = False): """Publish some payload to server.""" #print "PUBLISHING (",topic,"): ", payload payloadlen = len(payload) if topic is None or qos < 0 or qos > 2: print "PUBLISH:err inval" return NC.ERR_INVAL ...
[ "Publish", "some", "payload", "to", "server", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L278-L300
[ "def", "publish", "(", "self", ",", "topic", ",", "payload", "=", "None", ",", "qos", "=", "0", ",", "retain", "=", "False", ")", ":", "#print \"PUBLISHING (\",topic,\"): \", payload", "payloadlen", "=", "len", "(", "payload", ")", "if", "topic", "is", "No...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.handle_connack
Handle incoming CONNACK command.
nyamuk/nyamuk.py
def handle_connack(self): """Handle incoming CONNACK command.""" self.logger.info("CONNACK reveived") ret, flags = self.in_packet.read_byte() if ret != NC.ERR_SUCCESS: self.logger.error("error read byte") return ret # useful for v3.1.1 only ...
def handle_connack(self): """Handle incoming CONNACK command.""" self.logger.info("CONNACK reveived") ret, flags = self.in_packet.read_byte() if ret != NC.ERR_SUCCESS: self.logger.error("error read byte") return ret # useful for v3.1.1 only ...
[ "Handle", "incoming", "CONNACK", "command", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L302-L327
[ "def", "handle_connack", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"CONNACK reveived\"", ")", "ret", ",", "flags", "=", "self", ".", "in_packet", ".", "read_byte", "(", ")", "if", "ret", "!=", "NC", ".", "ERR_SUCCESS", ":", "sel...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.handle_pingresp
Handle incoming PINGRESP packet.
nyamuk/nyamuk.py
def handle_pingresp(self): """Handle incoming PINGRESP packet.""" self.logger.debug("PINGRESP received") self.push_event(event.EventPingResp()) return NC.ERR_SUCCESS
def handle_pingresp(self): """Handle incoming PINGRESP packet.""" self.logger.debug("PINGRESP received") self.push_event(event.EventPingResp()) return NC.ERR_SUCCESS
[ "Handle", "incoming", "PINGRESP", "packet", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L329-L333
[ "def", "handle_pingresp", "(", "self", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"PINGRESP received\"", ")", "self", ".", "push_event", "(", "event", ".", "EventPingResp", "(", ")", ")", "return", "NC", ".", "ERR_SUCCESS" ]
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.handle_suback
Handle incoming SUBACK packet.
nyamuk/nyamuk.py
def handle_suback(self): """Handle incoming SUBACK packet.""" self.logger.info("SUBACK received") ret, mid = self.in_packet.read_uint16() if ret != NC.ERR_SUCCESS: return ret qos_count = self.in_packet.remaining_length - self.in_packet.pos ...
def handle_suback(self): """Handle incoming SUBACK packet.""" self.logger.info("SUBACK received") ret, mid = self.in_packet.read_uint16() if ret != NC.ERR_SUCCESS: return ret qos_count = self.in_packet.remaining_length - self.in_packet.pos ...
[ "Handle", "incoming", "SUBACK", "packet", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L335-L367
[ "def", "handle_suback", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"SUBACK received\"", ")", "ret", ",", "mid", "=", "self", ".", "in_packet", ".", "read_uint16", "(", ")", "if", "ret", "!=", "NC", ".", "ERR_SUCCESS", ":", "retur...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.handle_unsuback
Handle incoming UNSUBACK packet.
nyamuk/nyamuk.py
def handle_unsuback(self): """Handle incoming UNSUBACK packet.""" self.logger.info("UNSUBACK received") ret, mid = self.in_packet.read_uint16() if ret != NC.ERR_SUCCESS: return ret evt = event.EventUnsuback(mid) self.push_event(evt) return NC.ERR_S...
def handle_unsuback(self): """Handle incoming UNSUBACK packet.""" self.logger.info("UNSUBACK received") ret, mid = self.in_packet.read_uint16() if ret != NC.ERR_SUCCESS: return ret evt = event.EventUnsuback(mid) self.push_event(evt) return NC.ERR_S...
[ "Handle", "incoming", "UNSUBACK", "packet", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L369-L381
[ "def", "handle_unsuback", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"UNSUBACK received\"", ")", "ret", ",", "mid", "=", "self", ".", "in_packet", ".", "read_uint16", "(", ")", "if", "ret", "!=", "NC", ".", "ERR_SUCCESS", ":", "r...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.handle_publish
Handle incoming PUBLISH packet.
nyamuk/nyamuk.py
def handle_publish(self): """Handle incoming PUBLISH packet.""" self.logger.debug("PUBLISH received") header = self.in_packet.command message = NyamukMsgAll() message.direction = NC.DIRECTION_IN message.dup = (header & 0x08) >> 3 message.msg.qos ...
def handle_publish(self): """Handle incoming PUBLISH packet.""" self.logger.debug("PUBLISH received") header = self.in_packet.command message = NyamukMsgAll() message.direction = NC.DIRECTION_IN message.dup = (header & 0x08) >> 3 message.msg.qos ...
[ "Handle", "incoming", "PUBLISH", "packet", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L388-L436
[ "def", "handle_publish", "(", "self", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"PUBLISH received\"", ")", "header", "=", "self", ".", "in_packet", ".", "command", "message", "=", "NyamukMsgAll", "(", ")", "message", ".", "direction", "=", "NC"...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.send_publish
Send PUBLISH.
nyamuk/nyamuk.py
def send_publish(self, mid, topic, payload, qos, retain, dup): """Send PUBLISH.""" self.logger.debug("Send PUBLISH") if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN #NOTE: payload may be any kind of data # yet if it is a unicode string we utf8-encode it...
def send_publish(self, mid, topic, payload, qos, retain, dup): """Send PUBLISH.""" self.logger.debug("Send PUBLISH") if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN #NOTE: payload may be any kind of data # yet if it is a unicode string we utf8-encode it...
[ "Send", "PUBLISH", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L438-L446
[ "def", "send_publish", "(", "self", ",", "mid", ",", "topic", ",", "payload", ",", "qos", ",", "retain", ",", "dup", ")", ":", "self", ".", "logger", ".", "debug", "(", "\"Send PUBLISH\"", ")", "if", "self", ".", "sock", "==", "NC", ".", "INVALID_SOC...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.handle_puback
Handle incoming PUBACK packet.
nyamuk/nyamuk.py
def handle_puback(self): """Handle incoming PUBACK packet.""" self.logger.info("PUBACK received") ret, mid = self.in_packet.read_uint16() if ret != NC.ERR_SUCCESS: return ret evt = event.EventPuback(mid) self.push_event(evt) return NC.ERR_SUCCESS
def handle_puback(self): """Handle incoming PUBACK packet.""" self.logger.info("PUBACK received") ret, mid = self.in_packet.read_uint16() if ret != NC.ERR_SUCCESS: return ret evt = event.EventPuback(mid) self.push_event(evt) return NC.ERR_SUCCESS
[ "Handle", "incoming", "PUBACK", "packet", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L455-L467
[ "def", "handle_puback", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"PUBACK received\"", ")", "ret", ",", "mid", "=", "self", ".", "in_packet", ".", "read_uint16", "(", ")", "if", "ret", "!=", "NC", ".", "ERR_SUCCESS", ":", "retur...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.handle_pubrec
Handle incoming PUBREC packet.
nyamuk/nyamuk.py
def handle_pubrec(self): """Handle incoming PUBREC packet.""" self.logger.info("PUBREC received") ret, mid = self.in_packet.read_uint16() if ret != NC.ERR_SUCCESS: return ret evt = event.EventPubrec(mid) self.push_event(evt) return NC.ERR_SUCCESS
def handle_pubrec(self): """Handle incoming PUBREC packet.""" self.logger.info("PUBREC received") ret, mid = self.in_packet.read_uint16() if ret != NC.ERR_SUCCESS: return ret evt = event.EventPubrec(mid) self.push_event(evt) return NC.ERR_SUCCESS
[ "Handle", "incoming", "PUBREC", "packet", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L469-L481
[ "def", "handle_pubrec", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"PUBREC received\"", ")", "ret", ",", "mid", "=", "self", ".", "in_packet", ".", "read_uint16", "(", ")", "if", "ret", "!=", "NC", ".", "ERR_SUCCESS", ":", "retur...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.handle_pubrel
Handle incoming PUBREL packet.
nyamuk/nyamuk.py
def handle_pubrel(self): """Handle incoming PUBREL packet.""" self.logger.info("PUBREL received") ret, mid = self.in_packet.read_uint16() if ret != NC.ERR_SUCCESS: return ret evt = event.EventPubrel(mid) self.push_event(evt) return NC.ERR_SUCCESS
def handle_pubrel(self): """Handle incoming PUBREL packet.""" self.logger.info("PUBREL received") ret, mid = self.in_packet.read_uint16() if ret != NC.ERR_SUCCESS: return ret evt = event.EventPubrel(mid) self.push_event(evt) return NC.ERR_SUCCESS
[ "Handle", "incoming", "PUBREL", "packet", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L483-L495
[ "def", "handle_pubrel", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"PUBREL received\"", ")", "ret", ",", "mid", "=", "self", ".", "in_packet", ".", "read_uint16", "(", ")", "if", "ret", "!=", "NC", ".", "ERR_SUCCESS", ":", "retur...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.handle_pubcomp
Handle incoming PUBCOMP packet.
nyamuk/nyamuk.py
def handle_pubcomp(self): """Handle incoming PUBCOMP packet.""" self.logger.info("PUBCOMP received") ret, mid = self.in_packet.read_uint16() if ret != NC.ERR_SUCCESS: return ret evt = event.EventPubcomp(mid) self.push_event(evt) return NC.ERR_SUCCE...
def handle_pubcomp(self): """Handle incoming PUBCOMP packet.""" self.logger.info("PUBCOMP received") ret, mid = self.in_packet.read_uint16() if ret != NC.ERR_SUCCESS: return ret evt = event.EventPubcomp(mid) self.push_event(evt) return NC.ERR_SUCCE...
[ "Handle", "incoming", "PUBCOMP", "packet", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L497-L509
[ "def", "handle_pubcomp", "(", "self", ")", ":", "self", ".", "logger", ".", "info", "(", "\"PUBCOMP received\"", ")", "ret", ",", "mid", "=", "self", ".", "in_packet", ".", "read_uint16", "(", ")", "if", "ret", "!=", "NC", ".", "ERR_SUCCESS", ":", "ret...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
Nyamuk.pubrec
Send PUBREC response to server.
nyamuk/nyamuk.py
def pubrec(self, mid): """Send PUBREC response to server.""" if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN self.logger.info("Send PUBREC (msgid=%s)", mid) pkt = MqttPkt() pkt.command = NC.CMD_PUBREC pkt.remaining_length = 2 ret = pkt.allo...
def pubrec(self, mid): """Send PUBREC response to server.""" if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN self.logger.info("Send PUBREC (msgid=%s)", mid) pkt = MqttPkt() pkt.command = NC.CMD_PUBREC pkt.remaining_length = 2 ret = pkt.allo...
[ "Send", "PUBREC", "response", "to", "server", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk.py#L552-L570
[ "def", "pubrec", "(", "self", ",", "mid", ")", ":", "if", "self", ".", "sock", "==", "NC", ".", "INVALID_SOCKET", ":", "return", "NC", ".", "ERR_NO_CONN", "self", ".", "logger", ".", "info", "(", "\"Send PUBREC (msgid=%s)\"", ",", "mid", ")", "pkt", "=...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
connect
Connect to some addr.
nyamuk/nyamuk_net.py
def connect(sock, addr): """Connect to some addr.""" try: sock.connect(addr) except ssl.SSLError as e: return (ssl.SSLError, e.strerror if e.strerror else e.message) except socket.herror as (_, msg): return (socket.herror, msg) except socket.gaierror as (_, msg): retu...
def connect(sock, addr): """Connect to some addr.""" try: sock.connect(addr) except ssl.SSLError as e: return (ssl.SSLError, e.strerror if e.strerror else e.message) except socket.herror as (_, msg): return (socket.herror, msg) except socket.gaierror as (_, msg): retu...
[ "Connect", "to", "some", "addr", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk_net.py#L17-L32
[ "def", "connect", "(", "sock", ",", "addr", ")", ":", "try", ":", "sock", ".", "connect", "(", "addr", ")", "except", "ssl", ".", "SSLError", "as", "e", ":", "return", "(", "ssl", ".", "SSLError", ",", "e", ".", "strerror", "if", "e", ".", "strer...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
read
Read from socket and return it's byte array representation. count = number of bytes to read
nyamuk/nyamuk_net.py
def read(sock, count): """Read from socket and return it's byte array representation. count = number of bytes to read """ data = None try: data = sock.recv(count) except ssl.SSLError as e: return data, e.errno, e.strerror if strerror else e.message except socket.herror as (e...
def read(sock, count): """Read from socket and return it's byte array representation. count = number of bytes to read """ data = None try: data = sock.recv(count) except ssl.SSLError as e: return data, e.errno, e.strerror if strerror else e.message except socket.herror as (e...
[ "Read", "from", "socket", "and", "return", "it", "s", "byte", "array", "representation", ".", "count", "=", "number", "of", "bytes", "to", "read" ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk_net.py#L34-L58
[ "def", "read", "(", "sock", ",", "count", ")", ":", "data", "=", "None", "try", ":", "data", "=", "sock", ".", "recv", "(", "count", ")", "except", "ssl", ".", "SSLError", "as", "e", ":", "return", "data", ",", "e", ".", "errno", ",", "e", ".",...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
write
Write payload to socket.
nyamuk/nyamuk_net.py
def write(sock, payload): """Write payload to socket.""" try: length = sock.send(payload) except ssl.SSLError as e: return -1, (ssl.SSLError, e.strerror if strerror else e.message) except socket.herror as (_, msg): return -1, (socket.error, msg) except socket.gaierror as (_, ...
def write(sock, payload): """Write payload to socket.""" try: length = sock.send(payload) except ssl.SSLError as e: return -1, (ssl.SSLError, e.strerror if strerror else e.message) except socket.herror as (_, msg): return -1, (socket.error, msg) except socket.gaierror as (_, ...
[ "Write", "payload", "to", "socket", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/nyamuk_net.py#L60-L75
[ "def", "write", "(", "sock", ",", "payload", ")", ":", "try", ":", "length", "=", "sock", ".", "send", "(", "payload", ")", "except", "ssl", ".", "SSLError", "as", "e", ":", "return", "-", "1", ",", "(", "ssl", ".", "SSLError", ",", "e", ".", "...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
MqttPkt.dump
Print packet content.
nyamuk/mqtt_pkt.py
def dump(self): """Print packet content.""" print "-----MqttPkt------" print "command = ", self.command print "have_remaining = ", self.have_remaining print "remaining_count = ", self.remaining_count print "mid = ", self.mid print "remaining_mult = ", self.remaini...
def dump(self): """Print packet content.""" print "-----MqttPkt------" print "command = ", self.command print "have_remaining = ", self.have_remaining print "remaining_count = ", self.remaining_count print "mid = ", self.mid print "remaining_mult = ", self.remaini...
[ "Print", "packet", "content", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/mqtt_pkt.py#L32-L45
[ "def", "dump", "(", "self", ")", ":", "print", "\"-----MqttPkt------\"", "print", "\"command = \"", ",", "self", ".", "command", "print", "\"have_remaining = \"", ",", "self", ".", "have_remaining", "print", "\"remaining_count = \"", ",", "self", ".", "remaining_cou...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
MqttPkt.alloc
from _mosquitto_packet_alloc.
nyamuk/mqtt_pkt.py
def alloc(self): """from _mosquitto_packet_alloc.""" byte = 0 remaining_bytes = bytearray(5) i = 0 remaining_length = self.remaining_length self.payload = None self.remaining_count = 0 loop_flag = True #self.dump() ...
def alloc(self): """from _mosquitto_packet_alloc.""" byte = 0 remaining_bytes = bytearray(5) i = 0 remaining_length = self.remaining_length self.payload = None self.remaining_count = 0 loop_flag = True #self.dump() ...
[ "from", "_mosquitto_packet_alloc", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/mqtt_pkt.py#L47-L88
[ "def", "alloc", "(", "self", ")", ":", "byte", "=", "0", "remaining_bytes", "=", "bytearray", "(", "5", ")", "i", "=", "0", "remaining_length", "=", "self", ".", "remaining_length", "self", ".", "payload", "=", "None", "self", ".", "remaining_count", "="...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
MqttPkt.connect_build
Build packet for CONNECT command.
nyamuk/mqtt_pkt.py
def connect_build(self, nyamuk, keepalive, clean_session, retain = 0, dup = 0, version = 3): """Build packet for CONNECT command.""" will = 0; will_topic = None byte = 0 client_id = utf8encode(nyamuk.client_id) username = utf8encode(nyamuk.username) if nyamuk.username is not No...
def connect_build(self, nyamuk, keepalive, clean_session, retain = 0, dup = 0, version = 3): """Build packet for CONNECT command.""" will = 0; will_topic = None byte = 0 client_id = utf8encode(nyamuk.client_id) username = utf8encode(nyamuk.username) if nyamuk.username is not No...
[ "Build", "packet", "for", "CONNECT", "command", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/mqtt_pkt.py#L100-L159
[ "def", "connect_build", "(", "self", ",", "nyamuk", ",", "keepalive", ",", "clean_session", ",", "retain", "=", "0", ",", "dup", "=", "0", ",", "version", "=", "3", ")", ":", "will", "=", "0", "will_topic", "=", "None", "byte", "=", "0", "client_id",...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
MqttPkt.write_string
Write a string to this packet.
nyamuk/mqtt_pkt.py
def write_string(self, string): """Write a string to this packet.""" self.write_uint16(len(string)) self.write_bytes(string, len(string))
def write_string(self, string): """Write a string to this packet.""" self.write_uint16(len(string)) self.write_bytes(string, len(string))
[ "Write", "a", "string", "to", "this", "packet", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/mqtt_pkt.py#L161-L164
[ "def", "write_string", "(", "self", ",", "string", ")", ":", "self", ".", "write_uint16", "(", "len", "(", "string", ")", ")", "self", ".", "write_bytes", "(", "string", ",", "len", "(", "string", ")", ")" ]
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
MqttPkt.write_uint16
Write 2 bytes.
nyamuk/mqtt_pkt.py
def write_uint16(self, word): """Write 2 bytes.""" self.write_byte(nyamuk_net.MOSQ_MSB(word)) self.write_byte(nyamuk_net.MOSQ_LSB(word))
def write_uint16(self, word): """Write 2 bytes.""" self.write_byte(nyamuk_net.MOSQ_MSB(word)) self.write_byte(nyamuk_net.MOSQ_LSB(word))
[ "Write", "2", "bytes", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/mqtt_pkt.py#L166-L169
[ "def", "write_uint16", "(", "self", ",", "word", ")", ":", "self", ".", "write_byte", "(", "nyamuk_net", ".", "MOSQ_MSB", "(", "word", ")", ")", "self", ".", "write_byte", "(", "nyamuk_net", ".", "MOSQ_LSB", "(", "word", ")", ")" ]
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
MqttPkt.write_byte
Write one byte.
nyamuk/mqtt_pkt.py
def write_byte(self, byte): """Write one byte.""" self.payload[self.pos] = byte self.pos = self.pos + 1
def write_byte(self, byte): """Write one byte.""" self.payload[self.pos] = byte self.pos = self.pos + 1
[ "Write", "one", "byte", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/mqtt_pkt.py#L171-L174
[ "def", "write_byte", "(", "self", ",", "byte", ")", ":", "self", ".", "payload", "[", "self", ".", "pos", "]", "=", "byte", "self", ".", "pos", "=", "self", ".", "pos", "+", "1" ]
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
MqttPkt.write_bytes
Write n number of bytes to this packet.
nyamuk/mqtt_pkt.py
def write_bytes(self, data, n): """Write n number of bytes to this packet.""" for pos in xrange(0, n): self.payload[self.pos + pos] = data[pos] self.pos += n
def write_bytes(self, data, n): """Write n number of bytes to this packet.""" for pos in xrange(0, n): self.payload[self.pos + pos] = data[pos] self.pos += n
[ "Write", "n", "number", "of", "bytes", "to", "this", "packet", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/mqtt_pkt.py#L176-L181
[ "def", "write_bytes", "(", "self", ",", "data", ",", "n", ")", ":", "for", "pos", "in", "xrange", "(", "0", ",", "n", ")", ":", "self", ".", "payload", "[", "self", ".", "pos", "+", "pos", "]", "=", "data", "[", "pos", "]", "self", ".", "pos"...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
MqttPkt.read_byte
Read a byte.
nyamuk/mqtt_pkt.py
def read_byte(self): """Read a byte.""" if self.pos + 1 > self.remaining_length: return NC.ERR_PROTOCOL, None byte = self.payload[self.pos] self.pos += 1 return NC.ERR_SUCCESS, byte
def read_byte(self): """Read a byte.""" if self.pos + 1 > self.remaining_length: return NC.ERR_PROTOCOL, None byte = self.payload[self.pos] self.pos += 1 return NC.ERR_SUCCESS, byte
[ "Read", "a", "byte", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/mqtt_pkt.py#L183-L191
[ "def", "read_byte", "(", "self", ")", ":", "if", "self", ".", "pos", "+", "1", ">", "self", ".", "remaining_length", ":", "return", "NC", ".", "ERR_PROTOCOL", ",", "None", "byte", "=", "self", ".", "payload", "[", "self", ".", "pos", "]", "self", "...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
MqttPkt.read_uint16
Read 2 bytes.
nyamuk/mqtt_pkt.py
def read_uint16(self): """Read 2 bytes.""" if self.pos + 2 > self.remaining_length: return NC.ERR_PROTOCOL msb = self.payload[self.pos] self.pos += 1 lsb = self.payload[self.pos] self.pos += 1 word = (msb << 8) + lsb return NC...
def read_uint16(self): """Read 2 bytes.""" if self.pos + 2 > self.remaining_length: return NC.ERR_PROTOCOL msb = self.payload[self.pos] self.pos += 1 lsb = self.payload[self.pos] self.pos += 1 word = (msb << 8) + lsb return NC...
[ "Read", "2", "bytes", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/mqtt_pkt.py#L193-L204
[ "def", "read_uint16", "(", "self", ")", ":", "if", "self", ".", "pos", "+", "2", ">", "self", ".", "remaining_length", ":", "return", "NC", ".", "ERR_PROTOCOL", "msb", "=", "self", ".", "payload", "[", "self", ".", "pos", "]", "self", ".", "pos", "...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
MqttPkt.read_bytes
Read count number of bytes.
nyamuk/mqtt_pkt.py
def read_bytes(self, count): """Read count number of bytes.""" if self.pos + count > self.remaining_length: return NC.ERR_PROTOCOL, None ba = bytearray(count) for x in xrange(0, count): ba[x] = self.payload[self.pos] self.pos += 1 ...
def read_bytes(self, count): """Read count number of bytes.""" if self.pos + count > self.remaining_length: return NC.ERR_PROTOCOL, None ba = bytearray(count) for x in xrange(0, count): ba[x] = self.payload[self.pos] self.pos += 1 ...
[ "Read", "count", "number", "of", "bytes", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/mqtt_pkt.py#L206-L216
[ "def", "read_bytes", "(", "self", ",", "count", ")", ":", "if", "self", ".", "pos", "+", "count", ">", "self", ".", "remaining_length", ":", "return", "NC", ".", "ERR_PROTOCOL", ",", "None", "ba", "=", "bytearray", "(", "count", ")", "for", "x", "in"...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
MqttPkt.read_string
Read string.
nyamuk/mqtt_pkt.py
def read_string(self): """Read string.""" rc, length = self.read_uint16() if rc != NC.ERR_SUCCESS: return rc, None if self.pos + length > self.remaining_length: return NC.ERR_PROTOCOL, None ba = bytearray(length) if ba is...
def read_string(self): """Read string.""" rc, length = self.read_uint16() if rc != NC.ERR_SUCCESS: return rc, None if self.pos + length > self.remaining_length: return NC.ERR_PROTOCOL, None ba = bytearray(length) if ba is...
[ "Read", "string", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/mqtt_pkt.py#L218-L236
[ "def", "read_string", "(", "self", ")", ":", "rc", ",", "length", "=", "self", ".", "read_uint16", "(", ")", "if", "rc", "!=", "NC", ".", "ERR_SUCCESS", ":", "return", "rc", ",", "None", "if", "self", ".", "pos", "+", "length", ">", "self", ".", ...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
BaseNyamuk.pop_event
Pop an event from event_list.
nyamuk/base_nyamuk.py
def pop_event(self): """Pop an event from event_list.""" if len(self.event_list) > 0: evt = self.event_list.pop(0) return evt return None
def pop_event(self): """Pop an event from event_list.""" if len(self.event_list) > 0: evt = self.event_list.pop(0) return evt return None
[ "Pop", "an", "event", "from", "event_list", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/base_nyamuk.py#L66-L71
[ "def", "pop_event", "(", "self", ")", ":", "if", "len", "(", "self", ".", "event_list", ")", ">", "0", ":", "evt", "=", "self", ".", "event_list", ".", "pop", "(", "0", ")", "return", "evt", "return", "None" ]
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
BaseNyamuk.mid_generate
Generate mid. TODO : check.
nyamuk/base_nyamuk.py
def mid_generate(self): """Generate mid. TODO : check.""" self.last_mid += 1 if self.last_mid == 0: self.last_mid += 1 return self.last_mid
def mid_generate(self): """Generate mid. TODO : check.""" self.last_mid += 1 if self.last_mid == 0: self.last_mid += 1 return self.last_mid
[ "Generate", "mid", ".", "TODO", ":", "check", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/base_nyamuk.py#L77-L82
[ "def", "mid_generate", "(", "self", ")", ":", "self", ".", "last_mid", "+=", "1", "if", "self", ".", "last_mid", "==", "0", ":", "self", ".", "last_mid", "+=", "1", "return", "self", ".", "last_mid" ]
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
BaseNyamuk.packet_queue
Enqueue packet to out_packet queue.
nyamuk/base_nyamuk.py
def packet_queue(self, pkt): """Enqueue packet to out_packet queue.""" pkt.pos = 0 pkt.to_process = pkt.packet_length self.out_packet.append(pkt) return NC.ERR_SUCCESS
def packet_queue(self, pkt): """Enqueue packet to out_packet queue.""" pkt.pos = 0 pkt.to_process = pkt.packet_length self.out_packet.append(pkt) return NC.ERR_SUCCESS
[ "Enqueue", "packet", "to", "out_packet", "queue", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/base_nyamuk.py#L87-L94
[ "def", "packet_queue", "(", "self", ",", "pkt", ")", ":", "pkt", ".", "pos", "=", "0", "pkt", ".", "to_process", "=", "pkt", ".", "packet_length", "self", ".", "out_packet", ".", "append", "(", "pkt", ")", "return", "NC", ".", "ERR_SUCCESS" ]
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
BaseNyamuk.packet_write
Write packet to network.
nyamuk/base_nyamuk.py
def packet_write(self): """Write packet to network.""" bytes_written = 0 if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN, bytes_written while len(self.out_packet) > 0: pkt = self.out_packet[0] write_length, status = nyamuk_ne...
def packet_write(self): """Write packet to network.""" bytes_written = 0 if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN, bytes_written while len(self.out_packet) > 0: pkt = self.out_packet[0] write_length, status = nyamuk_ne...
[ "Write", "packet", "to", "network", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/base_nyamuk.py#L96-L137
[ "def", "packet_write", "(", "self", ")", ":", "bytes_written", "=", "0", "if", "self", ".", "sock", "==", "NC", ".", "INVALID_SOCKET", ":", "return", "NC", ".", "ERR_NO_CONN", ",", "bytes_written", "while", "len", "(", "self", ".", "out_packet", ")", ">"...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
BaseNyamuk.packet_read
Read packet from network.
nyamuk/base_nyamuk.py
def packet_read(self): """Read packet from network.""" bytes_received = 0 if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN if self.in_packet.command == 0: ba_data, errnum, errmsg = nyamuk_net.read(self.sock, 1) if errnum == 0 ...
def packet_read(self): """Read packet from network.""" bytes_received = 0 if self.sock == NC.INVALID_SOCKET: return NC.ERR_NO_CONN if self.in_packet.command == 0: ba_data, errnum, errmsg = nyamuk_net.read(self.sock, 1) if errnum == 0 ...
[ "Read", "packet", "from", "network", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/base_nyamuk.py#L139-L230
[ "def", "packet_read", "(", "self", ")", ":", "bytes_received", "=", "0", "if", "self", ".", "sock", "==", "NC", ".", "INVALID_SOCKET", ":", "return", "NC", ".", "ERR_NO_CONN", "if", "self", ".", "in_packet", ".", "command", "==", "0", ":", "ba_data", "...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
BaseNyamuk.socket_close
Close our socket.
nyamuk/base_nyamuk.py
def socket_close(self): """Close our socket.""" if self.sock != NC.INVALID_SOCKET: self.sock.close() self.sock = NC.INVALID_SOCKET
def socket_close(self): """Close our socket.""" if self.sock != NC.INVALID_SOCKET: self.sock.close() self.sock = NC.INVALID_SOCKET
[ "Close", "our", "socket", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/base_nyamuk.py#L232-L236
[ "def", "socket_close", "(", "self", ")", ":", "if", "self", ".", "sock", "!=", "NC", ".", "INVALID_SOCKET", ":", "self", ".", "sock", ".", "close", "(", ")", "self", ".", "sock", "=", "NC", ".", "INVALID_SOCKET" ]
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
BaseNyamuk.build_publish_pkt
Build PUBLISH packet.
nyamuk/base_nyamuk.py
def build_publish_pkt(self, mid, topic, payload, qos, retain, dup): """Build PUBLISH packet.""" pkt = MqttPkt() payloadlen = len(payload) packetlen = 2 + len(topic) + payloadlen if qos > 0: packetlen += 2 pkt.mid = mid pkt.command = N...
def build_publish_pkt(self, mid, topic, payload, qos, retain, dup): """Build PUBLISH packet.""" pkt = MqttPkt() payloadlen = len(payload) packetlen = 2 + len(topic) + payloadlen if qos > 0: packetlen += 2 pkt.mid = mid pkt.command = N...
[ "Build", "PUBLISH", "packet", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/base_nyamuk.py#L251-L278
[ "def", "build_publish_pkt", "(", "self", ",", "mid", ",", "topic", ",", "payload", ",", "qos", ",", "retain", ",", "dup", ")", ":", "pkt", "=", "MqttPkt", "(", ")", "payloadlen", "=", "len", "(", "payload", ")", "packetlen", "=", "2", "+", "len", "...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
BaseNyamuk.send_simple_command
Send simple mqtt commands.
nyamuk/base_nyamuk.py
def send_simple_command(self, cmd): """Send simple mqtt commands.""" pkt = MqttPkt() pkt.command = cmd pkt.remaining_length = 0 ret = pkt.alloc() if ret != NC.ERR_SUCCESS: return ret return self.packet_queue(pkt)
def send_simple_command(self, cmd): """Send simple mqtt commands.""" pkt = MqttPkt() pkt.command = cmd pkt.remaining_length = 0 ret = pkt.alloc() if ret != NC.ERR_SUCCESS: return ret return self.packet_queue(pkt)
[ "Send", "simple", "mqtt", "commands", "." ]
iwanbk/nyamuk
python
https://github.com/iwanbk/nyamuk/blob/ac4c6028de288a4c8e0b332ae16eae889deb643d/nyamuk/base_nyamuk.py#L280-L291
[ "def", "send_simple_command", "(", "self", ",", "cmd", ")", ":", "pkt", "=", "MqttPkt", "(", ")", "pkt", ".", "command", "=", "cmd", "pkt", ".", "remaining_length", "=", "0", "ret", "=", "pkt", ".", "alloc", "(", ")", "if", "ret", "!=", "NC", ".", ...
ac4c6028de288a4c8e0b332ae16eae889deb643d
train
TorIpChanger.real_ip
The actual public IP of this host.
toripchanger/changer.py
def real_ip(self): """ The actual public IP of this host. """ if self._real_ip is None: response = get(ICANHAZIP) self._real_ip = self._get_response_text(response) return self._real_ip
def real_ip(self): """ The actual public IP of this host. """ if self._real_ip is None: response = get(ICANHAZIP) self._real_ip = self._get_response_text(response) return self._real_ip
[ "The", "actual", "public", "IP", "of", "this", "host", "." ]
DusanMadar/TorIpChanger
python
https://github.com/DusanMadar/TorIpChanger/blob/c2c4371e16f239b01ea36b82d971612bae00526d/toripchanger/changer.py#L72-L80
[ "def", "real_ip", "(", "self", ")", ":", "if", "self", ".", "_real_ip", "is", "None", ":", "response", "=", "get", "(", "ICANHAZIP", ")", "self", ".", "_real_ip", "=", "self", ".", "_get_response_text", "(", "response", ")", "return", "self", ".", "_re...
c2c4371e16f239b01ea36b82d971612bae00526d
train
TorIpChanger.get_current_ip
Get the current IP Tor is using. :returns str :raises TorIpError
toripchanger/changer.py
def get_current_ip(self): """ Get the current IP Tor is using. :returns str :raises TorIpError """ response = get(ICANHAZIP, proxies={"http": self.local_http_proxy}) if response.ok: return self._get_response_text(response) raise TorIpError("...
def get_current_ip(self): """ Get the current IP Tor is using. :returns str :raises TorIpError """ response = get(ICANHAZIP, proxies={"http": self.local_http_proxy}) if response.ok: return self._get_response_text(response) raise TorIpError("...
[ "Get", "the", "current", "IP", "Tor", "is", "using", "." ]
DusanMadar/TorIpChanger
python
https://github.com/DusanMadar/TorIpChanger/blob/c2c4371e16f239b01ea36b82d971612bae00526d/toripchanger/changer.py#L82-L94
[ "def", "get_current_ip", "(", "self", ")", ":", "response", "=", "get", "(", "ICANHAZIP", ",", "proxies", "=", "{", "\"http\"", ":", "self", ".", "local_http_proxy", "}", ")", "if", "response", ".", "ok", ":", "return", "self", ".", "_get_response_text", ...
c2c4371e16f239b01ea36b82d971612bae00526d
train
TorIpChanger.get_new_ip
Try to obtain new a usable TOR IP. :returns bool :raises TorIpError
toripchanger/changer.py
def get_new_ip(self): """ Try to obtain new a usable TOR IP. :returns bool :raises TorIpError """ attempts = 0 while True: if attempts == self.new_ip_max_attempts: raise TorIpError("Failed to obtain a new usable Tor IP") ...
def get_new_ip(self): """ Try to obtain new a usable TOR IP. :returns bool :raises TorIpError """ attempts = 0 while True: if attempts == self.new_ip_max_attempts: raise TorIpError("Failed to obtain a new usable Tor IP") ...
[ "Try", "to", "obtain", "new", "a", "usable", "TOR", "IP", "." ]
DusanMadar/TorIpChanger
python
https://github.com/DusanMadar/TorIpChanger/blob/c2c4371e16f239b01ea36b82d971612bae00526d/toripchanger/changer.py#L96-L124
[ "def", "get_new_ip", "(", "self", ")", ":", "attempts", "=", "0", "while", "True", ":", "if", "attempts", "==", "self", ".", "new_ip_max_attempts", ":", "raise", "TorIpError", "(", "\"Failed to obtain a new usable Tor IP\"", ")", "attempts", "+=", "1", "try", ...
c2c4371e16f239b01ea36b82d971612bae00526d
train
TorIpChanger._ip_is_usable
Check if the current Tor's IP is usable. :argument current_ip: current Tor IP :type current_ip: str :returns bool
toripchanger/changer.py
def _ip_is_usable(self, current_ip): """ Check if the current Tor's IP is usable. :argument current_ip: current Tor IP :type current_ip: str :returns bool """ # Consider IP addresses only. try: ipaddress.ip_address(current_ip) except ...
def _ip_is_usable(self, current_ip): """ Check if the current Tor's IP is usable. :argument current_ip: current Tor IP :type current_ip: str :returns bool """ # Consider IP addresses only. try: ipaddress.ip_address(current_ip) except ...
[ "Check", "if", "the", "current", "Tor", "s", "IP", "is", "usable", "." ]
DusanMadar/TorIpChanger
python
https://github.com/DusanMadar/TorIpChanger/blob/c2c4371e16f239b01ea36b82d971612bae00526d/toripchanger/changer.py#L140-L163
[ "def", "_ip_is_usable", "(", "self", ",", "current_ip", ")", ":", "# Consider IP addresses only.", "try", ":", "ipaddress", ".", "ip_address", "(", "current_ip", ")", "except", "ValueError", ":", "return", "False", "# Never use real IP.", "if", "current_ip", "==", ...
c2c4371e16f239b01ea36b82d971612bae00526d
train
TorIpChanger._manage_used_ips
Handle registering and releasing used Tor IPs. :argument current_ip: current Tor IP :type current_ip: str
toripchanger/changer.py
def _manage_used_ips(self, current_ip): """ Handle registering and releasing used Tor IPs. :argument current_ip: current Tor IP :type current_ip: str """ # Register current IP. self.used_ips.append(current_ip) # Release the oldest registred IP. i...
def _manage_used_ips(self, current_ip): """ Handle registering and releasing used Tor IPs. :argument current_ip: current Tor IP :type current_ip: str """ # Register current IP. self.used_ips.append(current_ip) # Release the oldest registred IP. i...
[ "Handle", "registering", "and", "releasing", "used", "Tor", "IPs", "." ]
DusanMadar/TorIpChanger
python
https://github.com/DusanMadar/TorIpChanger/blob/c2c4371e16f239b01ea36b82d971612bae00526d/toripchanger/changer.py#L165-L178
[ "def", "_manage_used_ips", "(", "self", ",", "current_ip", ")", ":", "# Register current IP.", "self", ".", "used_ips", ".", "append", "(", "current_ip", ")", "# Release the oldest registred IP.", "if", "self", ".", "reuse_threshold", ":", "if", "len", "(", "self"...
c2c4371e16f239b01ea36b82d971612bae00526d
train
TorIpChanger._obtain_new_ip
Change Tor's IP.
toripchanger/changer.py
def _obtain_new_ip(self): """ Change Tor's IP. """ with Controller.from_port( address=self.tor_address, port=self.tor_port ) as controller: controller.authenticate(password=self.tor_password) controller.signal(Signal.NEWNYM) # Wait til...
def _obtain_new_ip(self): """ Change Tor's IP. """ with Controller.from_port( address=self.tor_address, port=self.tor_port ) as controller: controller.authenticate(password=self.tor_password) controller.signal(Signal.NEWNYM) # Wait til...
[ "Change", "Tor", "s", "IP", "." ]
DusanMadar/TorIpChanger
python
https://github.com/DusanMadar/TorIpChanger/blob/c2c4371e16f239b01ea36b82d971612bae00526d/toripchanger/changer.py#L180-L191
[ "def", "_obtain_new_ip", "(", "self", ")", ":", "with", "Controller", ".", "from_port", "(", "address", "=", "self", ".", "tor_address", ",", "port", "=", "self", ".", "tor_port", ")", "as", "controller", ":", "controller", ".", "authenticate", "(", "passw...
c2c4371e16f239b01ea36b82d971612bae00526d
train
is_local_subsection
Returns True if command dict is "local subsection", meaning that it is "if", "else" or "for" (not a real call, but calls run_section recursively.
devassistant/excepthook.py
def is_local_subsection(command_dict): """Returns True if command dict is "local subsection", meaning that it is "if", "else" or "for" (not a real call, but calls run_section recursively.""" for local_com in ['if ', 'for ', 'else ']: if list(command_dict.keys())[0].startswith(local_com): ...
def is_local_subsection(command_dict): """Returns True if command dict is "local subsection", meaning that it is "if", "else" or "for" (not a real call, but calls run_section recursively.""" for local_com in ['if ', 'for ', 'else ']: if list(command_dict.keys())[0].startswith(local_com): ...
[ "Returns", "True", "if", "command", "dict", "is", "local", "subsection", "meaning", "that", "it", "is", "if", "else", "or", "for", "(", "not", "a", "real", "call", "but", "calls", "run_section", "recursively", "." ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/excepthook.py#L24-L31
[ "def", "is_local_subsection", "(", "command_dict", ")", ":", "for", "local_com", "in", "[", "'if '", ",", "'for '", ",", "'else '", "]", ":", "if", "list", "(", "command_dict", ".", "keys", "(", ")", ")", "[", "0", "]", ".", "startswith", "(", "local_c...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
_process_req_txt
Returns a processed request or raises an exception
devassistant/dapi/dapicli.py
def _process_req_txt(req): '''Returns a processed request or raises an exception''' if req.status_code == 404: return '' if req.status_code != 200: raise DapiCommError('Response of the server was {code}'.format(code=req.status_code)) return req.text
def _process_req_txt(req): '''Returns a processed request or raises an exception''' if req.status_code == 404: return '' if req.status_code != 200: raise DapiCommError('Response of the server was {code}'.format(code=req.status_code)) return req.text
[ "Returns", "a", "processed", "request", "or", "raises", "an", "exception" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L49-L55
[ "def", "_process_req_txt", "(", "req", ")", ":", "if", "req", ".", "status_code", "==", "404", ":", "return", "''", "if", "req", ".", "status_code", "!=", "200", ":", "raise", "DapiCommError", "(", "'Response of the server was {code}'", ".", "format", "(", "...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
_get_from_dapi_or_mirror
Tries to get the link form DAPI or the mirror
devassistant/dapi/dapicli.py
def _get_from_dapi_or_mirror(link): '''Tries to get the link form DAPI or the mirror''' exception = False try: req = requests.get(_api_url() + link, timeout=5) except requests.exceptions.RequestException: exception = True attempts = 1 while exception or str(req.status_code).star...
def _get_from_dapi_or_mirror(link): '''Tries to get the link form DAPI or the mirror''' exception = False try: req = requests.get(_api_url() + link, timeout=5) except requests.exceptions.RequestException: exception = True attempts = 1 while exception or str(req.status_code).star...
[ "Tries", "to", "get", "the", "link", "form", "DAPI", "or", "the", "mirror" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L63-L83
[ "def", "_get_from_dapi_or_mirror", "(", "link", ")", ":", "exception", "=", "False", "try", ":", "req", "=", "requests", ".", "get", "(", "_api_url", "(", ")", "+", "link", ",", "timeout", "=", "5", ")", "except", "requests", ".", "exceptions", ".", "R...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
_remove_api_url_from_link
Remove the API URL from the link if it is there
devassistant/dapi/dapicli.py
def _remove_api_url_from_link(link): '''Remove the API URL from the link if it is there''' if link.startswith(_api_url()): link = link[len(_api_url()):] if link.startswith(_api_url(mirror=True)): link = link[len(_api_url(mirror=True)):] return link
def _remove_api_url_from_link(link): '''Remove the API URL from the link if it is there''' if link.startswith(_api_url()): link = link[len(_api_url()):] if link.startswith(_api_url(mirror=True)): link = link[len(_api_url(mirror=True)):] return link
[ "Remove", "the", "API", "URL", "from", "the", "link", "if", "it", "is", "there" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L86-L92
[ "def", "_remove_api_url_from_link", "(", "link", ")", ":", "if", "link", ".", "startswith", "(", "_api_url", "(", ")", ")", ":", "link", "=", "link", "[", "len", "(", "_api_url", "(", ")", ")", ":", "]", "if", "link", ".", "startswith", "(", "_api_ur...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
data
Returns a dictionary from requested link
devassistant/dapi/dapicli.py
def data(link): '''Returns a dictionary from requested link''' link = _remove_api_url_from_link(link) req = _get_from_dapi_or_mirror(link) return _process_req(req)
def data(link): '''Returns a dictionary from requested link''' link = _remove_api_url_from_link(link) req = _get_from_dapi_or_mirror(link) return _process_req(req)
[ "Returns", "a", "dictionary", "from", "requested", "link" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L95-L99
[ "def", "data", "(", "link", ")", ":", "link", "=", "_remove_api_url_from_link", "(", "link", ")", "req", "=", "_get_from_dapi_or_mirror", "(", "link", ")", "return", "_process_req", "(", "req", ")" ]
2dbfeaa666a64127263664d18969c55d19ecc83e
train
_unpaginated
Returns a dictionary with all <what>, unpaginated
devassistant/dapi/dapicli.py
def _unpaginated(what): '''Returns a dictionary with all <what>, unpaginated''' page = data(what) results = page['results'] count = page['count'] while page['next']: page = data(page['next']) results += page['results'] count += page['count'] return {'results': results, 'c...
def _unpaginated(what): '''Returns a dictionary with all <what>, unpaginated''' page = data(what) results = page['results'] count = page['count'] while page['next']: page = data(page['next']) results += page['results'] count += page['count'] return {'results': results, 'c...
[ "Returns", "a", "dictionary", "with", "all", "<what", ">", "unpaginated" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L102-L111
[ "def", "_unpaginated", "(", "what", ")", ":", "page", "=", "data", "(", "what", ")", "results", "=", "page", "[", "'results'", "]", "count", "=", "page", "[", "'count'", "]", "while", "page", "[", "'next'", "]", ":", "page", "=", "data", "(", "page...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
search
Returns a dictionary with the search results
devassistant/dapi/dapicli.py
def search(q, **kwargs): '''Returns a dictionary with the search results''' data = {'q': q} for key, value in kwargs.items(): if value: if type(value) == bool: data[key] = 'on' else: data[key] = value return _unpaginated('search/?' + urlenc...
def search(q, **kwargs): '''Returns a dictionary with the search results''' data = {'q': q} for key, value in kwargs.items(): if value: if type(value) == bool: data[key] = 'on' else: data[key] = value return _unpaginated('search/?' + urlenc...
[ "Returns", "a", "dictionary", "with", "the", "search", "results" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L146-L155
[ "def", "search", "(", "q", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "'q'", ":", "q", "}", "for", "key", ",", "value", "in", "kwargs", ".", "items", "(", ")", ":", "if", "value", ":", "if", "type", "(", "value", ")", "==", "bool", ...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
format_users
Formats a list of users available on Dapi
devassistant/dapi/dapicli.py
def format_users(): '''Formats a list of users available on Dapi''' lines = [] u = users() count = u['count'] if not count: raise DapiCommError('Could not find any users on DAPI.') for user in u['results']: line = user['username'] if user['full_name']: line +=...
def format_users(): '''Formats a list of users available on Dapi''' lines = [] u = users() count = u['count'] if not count: raise DapiCommError('Could not find any users on DAPI.') for user in u['results']: line = user['username'] if user['full_name']: line +=...
[ "Formats", "a", "list", "of", "users", "available", "on", "Dapi" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L167-L179
[ "def", "format_users", "(", ")", ":", "lines", "=", "[", "]", "u", "=", "users", "(", ")", "count", "=", "u", "[", "'count'", "]", "if", "not", "count", ":", "raise", "DapiCommError", "(", "'Could not find any users on DAPI.'", ")", "for", "user", "in", ...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
format_daps
Formats a list of metadaps available on Dapi
devassistant/dapi/dapicli.py
def format_daps(simple=False, skip_installed=False): '''Formats a list of metadaps available on Dapi''' lines= [] m = metadaps() if not m['count']: logger.info('Could not find any daps') return for mdap in sorted(m['results'], key=lambda mdap: mdap['package_name']): if skip_i...
def format_daps(simple=False, skip_installed=False): '''Formats a list of metadaps available on Dapi''' lines= [] m = metadaps() if not m['count']: logger.info('Could not find any daps') return for mdap in sorted(m['results'], key=lambda mdap: mdap['package_name']): if skip_i...
[ "Formats", "a", "list", "of", "metadaps", "available", "on", "Dapi" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L182-L197
[ "def", "format_daps", "(", "simple", "=", "False", ",", "skip_installed", "=", "False", ")", ":", "lines", "=", "[", "]", "m", "=", "metadaps", "(", ")", "if", "not", "m", "[", "'count'", "]", ":", "logger", ".", "info", "(", "'Could not find any daps'...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
_get_metadap_dap
Return data for dap of given or latest version.
devassistant/dapi/dapicli.py
def _get_metadap_dap(name, version=''): '''Return data for dap of given or latest version.''' m = metadap(name) if not m: raise DapiCommError('DAP {dap} not found.'.format(dap=name)) if not version: d = m['latest_stable'] or m['latest'] if d: d = data(d) else: ...
def _get_metadap_dap(name, version=''): '''Return data for dap of given or latest version.''' m = metadap(name) if not m: raise DapiCommError('DAP {dap} not found.'.format(dap=name)) if not version: d = m['latest_stable'] or m['latest'] if d: d = data(d) else: ...
[ "Return", "data", "for", "dap", "of", "given", "or", "latest", "version", "." ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L200-L214
[ "def", "_get_metadap_dap", "(", "name", ",", "version", "=", "''", ")", ":", "m", "=", "metadap", "(", "name", ")", "if", "not", "m", ":", "raise", "DapiCommError", "(", "'DAP {dap} not found.'", ".", "format", "(", "dap", "=", "name", ")", ")", "if", ...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
format_dap_from_dapi
Formats information about given DAP from DAPI in a human readable form to list of lines
devassistant/dapi/dapicli.py
def format_dap_from_dapi(name, version='', full=False): '''Formats information about given DAP from DAPI in a human readable form to list of lines''' lines = [] m, d = _get_metadap_dap(name, version) if d: # Determining label width labels = BASIC_LABELS + ['average_rank'] # average_rank...
def format_dap_from_dapi(name, version='', full=False): '''Formats information about given DAP from DAPI in a human readable form to list of lines''' lines = [] m, d = _get_metadap_dap(name, version) if d: # Determining label width labels = BASIC_LABELS + ['average_rank'] # average_rank...
[ "Formats", "information", "about", "given", "DAP", "from", "DAPI", "in", "a", "human", "readable", "form", "to", "list", "of", "lines" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L217-L252
[ "def", "format_dap_from_dapi", "(", "name", ",", "version", "=", "''", ",", "full", "=", "False", ")", ":", "lines", "=", "[", "]", "m", ",", "d", "=", "_get_metadap_dap", "(", "name", ",", "version", ")", "if", "d", ":", "# Determining label width", "...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
format_local_dap
Formaqts information about the given local DAP in a human readable form to list of lines
devassistant/dapi/dapicli.py
def format_local_dap(dap, full=False, **kwargs): '''Formaqts information about the given local DAP in a human readable form to list of lines''' lines = [] # Determining label width label_width = dapi.DapFormatter.calculate_offset(BASIC_LABELS) # Metadata lines.append(dapi.DapFormatter.format_m...
def format_local_dap(dap, full=False, **kwargs): '''Formaqts information about the given local DAP in a human readable form to list of lines''' lines = [] # Determining label width label_width = dapi.DapFormatter.calculate_offset(BASIC_LABELS) # Metadata lines.append(dapi.DapFormatter.format_m...
[ "Formaqts", "information", "about", "the", "given", "local", "DAP", "in", "a", "human", "readable", "form", "to", "list", "of", "lines" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L255-L281
[ "def", "format_local_dap", "(", "dap", ",", "full", "=", "False", ",", "*", "*", "kwargs", ")", ":", "lines", "=", "[", "]", "# Determining label width", "label_width", "=", "dapi", ".", "DapFormatter", ".", "calculate_offset", "(", "BASIC_LABELS", ")", "# M...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
format_installed_dap
Formats information about an installed DAP in a human readable form to list of lines
devassistant/dapi/dapicli.py
def format_installed_dap(name, full=False): '''Formats information about an installed DAP in a human readable form to list of lines''' dap_data = get_installed_daps_detailed().get(name) if not dap_data: raise DapiLocalError('DAP "{dap}" is not installed, can not query for info.'.format(dap=name)) ...
def format_installed_dap(name, full=False): '''Formats information about an installed DAP in a human readable form to list of lines''' dap_data = get_installed_daps_detailed().get(name) if not dap_data: raise DapiLocalError('DAP "{dap}" is not installed, can not query for info.'.format(dap=name)) ...
[ "Formats", "information", "about", "an", "installed", "DAP", "in", "a", "human", "readable", "form", "to", "list", "of", "lines" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L284-L299
[ "def", "format_installed_dap", "(", "name", ",", "full", "=", "False", ")", ":", "dap_data", "=", "get_installed_daps_detailed", "(", ")", ".", "get", "(", "name", ")", "if", "not", "dap_data", ":", "raise", "DapiLocalError", "(", "'DAP \"{dap}\" is not installe...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
format_installed_dap_list
Formats all installed DAPs in a human readable form to list of lines
devassistant/dapi/dapicli.py
def format_installed_dap_list(simple=False): '''Formats all installed DAPs in a human readable form to list of lines''' lines = [] if simple: for pkg in sorted(get_installed_daps()): lines.append(pkg) else: for pkg, instances in sorted(get_installed_daps_detailed().items()): ...
def format_installed_dap_list(simple=False): '''Formats all installed DAPs in a human readable form to list of lines''' lines = [] if simple: for pkg in sorted(get_installed_daps()): lines.append(pkg) else: for pkg, instances in sorted(get_installed_daps_detailed().items()): ...
[ "Formats", "all", "installed", "DAPs", "in", "a", "human", "readable", "form", "to", "list", "of", "lines" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L302-L319
[ "def", "format_installed_dap_list", "(", "simple", "=", "False", ")", ":", "lines", "=", "[", "]", "if", "simple", ":", "for", "pkg", "in", "sorted", "(", "get_installed_daps", "(", ")", ")", ":", "lines", ".", "append", "(", "pkg", ")", "else", ":", ...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
_get_assistants_snippets
Get Assistants and Snippets for a given DAP name on a given path
devassistant/dapi/dapicli.py
def _get_assistants_snippets(path, name): '''Get Assistants and Snippets for a given DAP name on a given path''' result = [] subdirs = {'assistants': 2, 'snippets': 1} # Values used for stripping leading path tokens for loc in subdirs: for root, dirs, files in os.walk(os.path.join(path, loc)): ...
def _get_assistants_snippets(path, name): '''Get Assistants and Snippets for a given DAP name on a given path''' result = [] subdirs = {'assistants': 2, 'snippets': 1} # Values used for stripping leading path tokens for loc in subdirs: for root, dirs, files in os.walk(os.path.join(path, loc)): ...
[ "Get", "Assistants", "and", "Snippets", "for", "a", "given", "DAP", "name", "on", "a", "given", "path" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L322-L334
[ "def", "_get_assistants_snippets", "(", "path", ",", "name", ")", ":", "result", "=", "[", "]", "subdirs", "=", "{", "'assistants'", ":", "2", ",", "'snippets'", ":", "1", "}", "# Values used for stripping leading path tokens", "for", "loc", "in", "subdirs", "...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
format_search
Formats the results of a search
devassistant/dapi/dapicli.py
def format_search(q, **kwargs): '''Formats the results of a search''' m = search(q, **kwargs) count = m['count'] if not count: raise DapiCommError('Could not find any DAP packages for your query.') return for mdap in m['results']: mdap = mdap['content_object'] return ...
def format_search(q, **kwargs): '''Formats the results of a search''' m = search(q, **kwargs) count = m['count'] if not count: raise DapiCommError('Could not find any DAP packages for your query.') return for mdap in m['results']: mdap = mdap['content_object'] return ...
[ "Formats", "the", "results", "of", "a", "search" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L337-L346
[ "def", "format_search", "(", "q", ",", "*", "*", "kwargs", ")", ":", "m", "=", "search", "(", "q", ",", "*", "*", "kwargs", ")", "count", "=", "m", "[", "'count'", "]", "if", "not", "count", ":", "raise", "DapiCommError", "(", "'Could not find any DA...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
get_installed_daps
Returns a set of all installed daps Either in the given location or in all of them
devassistant/dapi/dapicli.py
def get_installed_daps(location=None, skip_distro=False): '''Returns a set of all installed daps Either in the given location or in all of them''' if location: locations = [location] else: locations = _data_dirs() s = set() for loc in locations: if skip_distro and loc == ...
def get_installed_daps(location=None, skip_distro=False): '''Returns a set of all installed daps Either in the given location or in all of them''' if location: locations = [location] else: locations = _data_dirs() s = set() for loc in locations: if skip_distro and loc == ...
[ "Returns", "a", "set", "of", "all", "installed", "daps", "Either", "in", "the", "given", "location", "or", "in", "all", "of", "them" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L349-L363
[ "def", "get_installed_daps", "(", "location", "=", "None", ",", "skip_distro", "=", "False", ")", ":", "if", "location", ":", "locations", "=", "[", "location", "]", "else", ":", "locations", "=", "_data_dirs", "(", ")", "s", "=", "set", "(", ")", "for...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
get_installed_daps_detailed
Returns a dictionary with all installed daps and their versions and locations First version and location in the dap's list is the one that is preferred
devassistant/dapi/dapicli.py
def get_installed_daps_detailed(): '''Returns a dictionary with all installed daps and their versions and locations First version and location in the dap's list is the one that is preferred''' daps = {} for loc in _data_dirs(): s = get_installed_daps(loc) for dap in s: if dap...
def get_installed_daps_detailed(): '''Returns a dictionary with all installed daps and their versions and locations First version and location in the dap's list is the one that is preferred''' daps = {} for loc in _data_dirs(): s = get_installed_daps(loc) for dap in s: if dap...
[ "Returns", "a", "dictionary", "with", "all", "installed", "daps", "and", "their", "versions", "and", "locations", "First", "version", "and", "location", "in", "the", "dap", "s", "list", "is", "the", "one", "that", "is", "preferred" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L366-L376
[ "def", "get_installed_daps_detailed", "(", ")", ":", "daps", "=", "{", "}", "for", "loc", "in", "_data_dirs", "(", ")", ":", "s", "=", "get_installed_daps", "(", "loc", ")", "for", "dap", "in", "s", ":", "if", "dap", "not", "in", "daps", ":", "daps",...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
download_dap
Download a dap to a given or temporary directory Return a path to that file together with information if the directory should be later deleted
devassistant/dapi/dapicli.py
def download_dap(name, version='', d='', directory=''): '''Download a dap to a given or temporary directory Return a path to that file together with information if the directory should be later deleted ''' if not d: m, d = _get_metadap_dap(name, version) if directory: _dir = director...
def download_dap(name, version='', d='', directory=''): '''Download a dap to a given or temporary directory Return a path to that file together with information if the directory should be later deleted ''' if not d: m, d = _get_metadap_dap(name, version) if directory: _dir = director...
[ "Download", "a", "dap", "to", "a", "given", "or", "temporary", "directory", "Return", "a", "path", "to", "that", "file", "together", "with", "information", "if", "the", "directory", "should", "be", "later", "deleted" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L448-L472
[ "def", "download_dap", "(", "name", ",", "version", "=", "''", ",", "d", "=", "''", ",", "directory", "=", "''", ")", ":", "if", "not", "d", ":", "m", ",", "d", "=", "_get_metadap_dap", "(", "name", ",", "version", ")", "if", "directory", ":", "_...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
install_dap_from_path
Installs a dap from a given path
devassistant/dapi/dapicli.py
def install_dap_from_path(path, update=False, update_allpaths=False, first=True, force=False, nodeps=False, reinstall=False, __ui__=''): '''Installs a dap from a given path''' will_uninstall = False dap_obj = dapi.Dap(path) name = dap_obj.meta['package_name'] if name in ge...
def install_dap_from_path(path, update=False, update_allpaths=False, first=True, force=False, nodeps=False, reinstall=False, __ui__=''): '''Installs a dap from a given path''' will_uninstall = False dap_obj = dapi.Dap(path) name = dap_obj.meta['package_name'] if name in ge...
[ "Installs", "a", "dap", "from", "a", "given", "path" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L475-L568
[ "def", "install_dap_from_path", "(", "path", ",", "update", "=", "False", ",", "update_allpaths", "=", "False", ",", "first", "=", "True", ",", "force", "=", "False", ",", "nodeps", "=", "False", ",", "reinstall", "=", "False", ",", "__ui__", "=", "''", ...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
_strip_version_from_dependency
For given dependency string, return only the package name
devassistant/dapi/dapicli.py
def _strip_version_from_dependency(dep): '''For given dependency string, return only the package name''' usedmark = '' for mark in '< > ='.split(): split = dep.split(mark) if len(split) > 1: usedmark = mark break if usedmark: return split[0].strip() el...
def _strip_version_from_dependency(dep): '''For given dependency string, return only the package name''' usedmark = '' for mark in '< > ='.split(): split = dep.split(mark) if len(split) > 1: usedmark = mark break if usedmark: return split[0].strip() el...
[ "For", "given", "dependency", "string", "return", "only", "the", "package", "name" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L571-L582
[ "def", "_strip_version_from_dependency", "(", "dep", ")", ":", "usedmark", "=", "''", "for", "mark", "in", "'< > ='", ".", "split", "(", ")", ":", "split", "=", "dep", ".", "split", "(", "mark", ")", "if", "len", "(", "split", ")", ">", "1", ":", "...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
get_installed_version_of
Gets the installed version of the given dap or None if not installed Searches in all dirs by default, otherwise in the given one
devassistant/dapi/dapicli.py
def get_installed_version_of(name, location=None): '''Gets the installed version of the given dap or None if not installed Searches in all dirs by default, otherwise in the given one''' if location: locations = [location] else: locations = _data_dirs() for loc in locations: ...
def get_installed_version_of(name, location=None): '''Gets the installed version of the given dap or None if not installed Searches in all dirs by default, otherwise in the given one''' if location: locations = [location] else: locations = _data_dirs() for loc in locations: ...
[ "Gets", "the", "installed", "version", "of", "the", "given", "dap", "or", "None", "if", "not", "installed", "Searches", "in", "all", "dirs", "by", "default", "otherwise", "in", "the", "given", "one" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L585-L599
[ "def", "get_installed_version_of", "(", "name", ",", "location", "=", "None", ")", ":", "if", "location", ":", "locations", "=", "[", "location", "]", "else", ":", "locations", "=", "_data_dirs", "(", ")", "for", "loc", "in", "locations", ":", "if", "nam...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
_get_dependencies_of
Returns list of first level dependencies of the given installed dap or dap from Dapi if not installed If a location is specified, this only checks for dap installed in that path and return [] if the dap is not located there
devassistant/dapi/dapicli.py
def _get_dependencies_of(name, location=None): ''' Returns list of first level dependencies of the given installed dap or dap from Dapi if not installed If a location is specified, this only checks for dap installed in that path and return [] if the dap is not located there ''' if not locat...
def _get_dependencies_of(name, location=None): ''' Returns list of first level dependencies of the given installed dap or dap from Dapi if not installed If a location is specified, this only checks for dap installed in that path and return [] if the dap is not located there ''' if not locat...
[ "Returns", "list", "of", "first", "level", "dependencies", "of", "the", "given", "installed", "dap", "or", "dap", "from", "Dapi", "if", "not", "installed", "If", "a", "location", "is", "specified", "this", "only", "checks", "for", "dap", "installed", "in", ...
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L610-L628
[ "def", "_get_dependencies_of", "(", "name", ",", "location", "=", "None", ")", ":", "if", "not", "location", ":", "detailed_dap_list", "=", "get_installed_daps_detailed", "(", ")", "if", "name", "not", "in", "detailed_dap_list", ":", "return", "_get_api_dependenci...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
_get_all_dependencies_of
Returns list of dependencies of the given dap from Dapi recursively
devassistant/dapi/dapicli.py
def _get_all_dependencies_of(name, deps=set(), force=False): '''Returns list of dependencies of the given dap from Dapi recursively''' first_deps = _get_api_dependencies_of(name, force=force) for dep in first_deps: dep = _strip_version_from_dependency(dep) if dep in deps: continu...
def _get_all_dependencies_of(name, deps=set(), force=False): '''Returns list of dependencies of the given dap from Dapi recursively''' first_deps = _get_api_dependencies_of(name, force=force) for dep in first_deps: dep = _strip_version_from_dependency(dep) if dep in deps: continu...
[ "Returns", "list", "of", "dependencies", "of", "the", "given", "dap", "from", "Dapi", "recursively" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L631-L642
[ "def", "_get_all_dependencies_of", "(", "name", ",", "deps", "=", "set", "(", ")", ",", "force", "=", "False", ")", ":", "first_deps", "=", "_get_api_dependencies_of", "(", "name", ",", "force", "=", "force", ")", "for", "dep", "in", "first_deps", ":", "...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
_get_api_dependencies_of
Returns list of first level dependencies of the given dap from Dapi
devassistant/dapi/dapicli.py
def _get_api_dependencies_of(name, version='', force=False): '''Returns list of first level dependencies of the given dap from Dapi''' m, d = _get_metadap_dap(name, version=version) # We need the dependencies to install the dap, # if the dap is unsupported, raise an exception here if not force and n...
def _get_api_dependencies_of(name, version='', force=False): '''Returns list of first level dependencies of the given dap from Dapi''' m, d = _get_metadap_dap(name, version=version) # We need the dependencies to install the dap, # if the dap is unsupported, raise an exception here if not force and n...
[ "Returns", "list", "of", "first", "level", "dependencies", "of", "the", "given", "dap", "from", "Dapi" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L645-L654
[ "def", "_get_api_dependencies_of", "(", "name", ",", "version", "=", "''", ",", "force", "=", "False", ")", ":", "m", ",", "d", "=", "_get_metadap_dap", "(", "name", ",", "version", "=", "version", ")", "# We need the dependencies to install the dap,", "# if the...
2dbfeaa666a64127263664d18969c55d19ecc83e
train
install_dap
Install a dap from dapi If update is True, it will remove previously installed daps of the same name
devassistant/dapi/dapicli.py
def install_dap(name, version='', update=False, update_allpaths=False, first=True, force=False, nodeps=False, reinstall=False, __ui__=''): '''Install a dap from dapi If update is True, it will remove previously installed daps of the same name''' m, d = _get_metadap_dap(name, version) if ...
def install_dap(name, version='', update=False, update_allpaths=False, first=True, force=False, nodeps=False, reinstall=False, __ui__=''): '''Install a dap from dapi If update is True, it will remove previously installed daps of the same name''' m, d = _get_metadap_dap(name, version) if ...
[ "Install", "a", "dap", "from", "dapi", "If", "update", "is", "True", "it", "will", "remove", "previously", "installed", "daps", "of", "the", "same", "name" ]
devassistant/devassistant
python
https://github.com/devassistant/devassistant/blob/2dbfeaa666a64127263664d18969c55d19ecc83e/devassistant/dapi/dapicli.py#L657-L682
[ "def", "install_dap", "(", "name", ",", "version", "=", "''", ",", "update", "=", "False", ",", "update_allpaths", "=", "False", ",", "first", "=", "True", ",", "force", "=", "False", ",", "nodeps", "=", "False", ",", "reinstall", "=", "False", ",", ...
2dbfeaa666a64127263664d18969c55d19ecc83e