Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
command_admins
(bot, user, channel, args)
Add, remove or list admins. Usage: admins [(add|del) <nick>,...]
Add, remove or list admins. Usage: admins [(add|del) <nick>,...]
def command_admins(bot, user, channel, args): "Add, remove or list admins. Usage: admins [(add|del) <nick>,...]" if permissions(user) < 20: # 0 public, 1-9 undefined, 10-19 admin, 20 root return bot.say(channel, "{}, insufficient permissions.".format( get_nick(user))) supera...
[ "def", "command_admins", "(", "bot", ",", "user", ",", "channel", ",", "args", ")", ":", "if", "permissions", "(", "user", ")", "<", "20", ":", "# 0 public, 1-9 undefined, 10-19 admin, 20 root", "return", "bot", ".", "say", "(", "channel", ",", "\"{}, insuffic...
[ 36, 0 ]
[ 89, 60 ]
python
en
['en', 'mt', 'en']
True
command_rehash
(bot, user, channel, args)
Rehashes all available modules to reflect any changes.
Rehashes all available modules to reflect any changes.
def command_rehash(bot, user, channel, args): "Rehashes all available modules to reflect any changes." if permissions(user) < 20: # 0 public, 1-9 undefined, 10-19 admin, 20 root return bot.say(channel, "{}, insufficient permissions.".format( get_nick(user))) try: lo...
[ "def", "command_rehash", "(", "bot", ",", "user", ",", "channel", ",", "args", ")", ":", "if", "permissions", "(", "user", ")", "<", "20", ":", "# 0 public, 1-9 undefined, 10-19 admin, 20 root", "return", "bot", ".", "say", "(", "channel", ",", "\"{}, insuffic...
[ 92, 0 ]
[ 109, 45 ]
python
en
['en', 'en', 'en']
True
command_quit
(bot, user, channel, args)
Ends this or optionally all client instances. Usage: quit [all].
Ends this or optionally all client instances. Usage: quit [all].
def command_quit(bot, user, channel, args): "Ends this or optionally all client instances. Usage: quit [all]." if permissions(user) < 20: # 0 public, 1-9 undefined, 10-19 admin, 20 root return bot.say(channel, "{}, insufficient permissions.".format( get_nick(user))) if args...
[ "def", "command_quit", "(", "bot", ",", "user", ",", "channel", ",", "args", ")", ":", "if", "permissions", "(", "user", ")", "<", "20", ":", "# 0 public, 1-9 undefined, 10-19 admin, 20 root", "return", "bot", ".", "say", "(", "channel", ",", "\"{}, insufficie...
[ 112, 0 ]
[ 125, 14 ]
python
en
['en', 'en', 'en']
True
command_kick
(bot, user, channel, args, reason=None)
Usage: kick <user> [<reason>]
Usage: kick <user> [<reason>]
def command_kick(bot, user, channel, args, reason=None): "Usage: kick <user> [<reason>]" if permissions(user) < 10: # 0 public, 1-9 undefined, 10-19 admin, 20 root return bot.say(channel, "{}, insufficient permissions.".format( get_nick(user))) args = [i for i in args.partit...
[ "def", "command_kick", "(", "bot", ",", "user", ",", "channel", ",", "args", ",", "reason", "=", "None", ")", ":", "if", "permissions", "(", "user", ")", "<", "10", ":", "# 0 public, 1-9 undefined, 10-19 admin, 20 root", "return", "bot", ".", "say", "(", "...
[ 128, 0 ]
[ 141, 34 ]
python
en
['en', 'jv', 'sw']
False
command_mode
(bot, user, channel, args)
Usage: mode <(+|-)mode> <user> [<channel>]
Usage: mode <(+|-)mode> <user> [<channel>]
def command_mode(bot, user, channel, args): "Usage: mode <(+|-)mode> <user> [<channel>]" # TODO: "all" argument instead of user. if permissions(user) < 20: # 0 public, 1-9 undefined, 10-19 admin, 20 root return bot.say(channel, "{}, insufficient permissions.".format( get_nick...
[ "def", "command_mode", "(", "bot", ",", "user", ",", "channel", ",", "args", ")", ":", "# TODO: \"all\" argument instead of user.", "if", "permissions", "(", "user", ")", "<", "20", ":", "# 0 public, 1-9 undefined, 10-19 admin, 20 root", "return", "bot", ".", "say",...
[ 144, 0 ]
[ 168, 50 ]
python
en
['en', 'en', 'ur']
True
command_tempban
(bot, user, channel, args)
Usage: tempban <duration> <user> [<channel>]
Usage: tempban <duration> <user> [<channel>]
def command_tempban(bot, user, channel, args): "Usage: tempban <duration> <user> [<channel>]" if permissions(user) < 20: # 0 public, 1-9 undefined, 10-19 admin, 20 root return bot.say(channel, "{}, insufficient permissions.".format( get_nick(user))) args = args.split() i...
[ "def", "command_tempban", "(", "bot", ",", "user", ",", "channel", ",", "args", ")", ":", "if", "permissions", "(", "user", ")", "<", "20", ":", "# 0 public, 1-9 undefined, 10-19 admin, 20 root", "return", "bot", ".", "say", "(", "channel", ",", "\"{}, insuffi...
[ 171, 0 ]
[ 206, 73 ]
python
en
['hu', 'en', 'ur']
False
command_setnick
(bot, user, channel, args)
Change the bots nickname. Usage: setnick <nick>
Change the bots nickname. Usage: setnick <nick>
def command_setnick(bot, user, channel, args): "Change the bots nickname. Usage: setnick <nick>" if permissions(user) < 20: # 0 public, 1-9 undefined, 10-19 admin, 20 root return bot.say(channel, "{}, insufficient permissions.".format( get_nick(user))) args = args.split() ...
[ "def", "command_setnick", "(", "bot", ",", "user", ",", "channel", ",", "args", ")", ":", "if", "permissions", "(", "user", ")", "<", "20", ":", "# 0 public, 1-9 undefined, 10-19 admin, 20 root", "return", "bot", ".", "say", "(", "channel", ",", "\"{}, insuffi...
[ 209, 0 ]
[ 222, 54 ]
python
en
['en', 'ceb', 'en']
True
command_setlead
(bot, user, channel, args)
Change the bots command identifier. Usage: setlead <lead>.
Change the bots command identifier. Usage: setlead <lead>.
def command_setlead(bot, user, channel, args): "Change the bots command identifier. Usage: setlead <lead>." perms, nick = permissions(user), get_nick(user) if perms < 20: # 0 public, 1-9 undefined, 10-19 admin, 20 root return bot.say(channel, "{}, insufficient permissions.".format(nick)) if no...
[ "def", "command_setlead", "(", "bot", ",", "user", ",", "channel", ",", "args", ")", ":", "perms", ",", "nick", "=", "permissions", "(", "user", ")", ",", "get_nick", "(", "user", ")", "if", "perms", "<", "20", ":", "# 0 public, 1-9 undefined, 10-19 admin,...
[ 225, 0 ]
[ 240, 37 ]
python
en
['en', 'fy', 'en']
True
command_setmin
(bot, user, channel, args)
Change the bots nickname. Usage: setnick <nick>
Change the bots nickname. Usage: setnick <nick>
def command_setmin(bot, user, channel, args): "Change the bots nickname. Usage: setnick <nick>" perms, nick = permissions(user), get_nick(user) if perms < 20: # 0 public, 1-9 undefined, 10-19 admin, 20 root return bot.say(channel, "{}, insufficient permissions.".format(nick)) if len(args.split...
[ "def", "command_setmin", "(", "bot", ",", "user", ",", "channel", ",", "args", ")", ":", "perms", ",", "nick", "=", "permissions", "(", "user", ")", ",", "get_nick", "(", "user", ")", "if", "perms", "<", "20", ":", "# 0 public, 1-9 undefined, 10-19 admin, ...
[ 243, 0 ]
[ 259, 79 ]
python
en
['en', 'ceb', 'en']
True
command_settopic
(bot, user, channel, args)
Set the channel topic. Usage: settopic <topic>
Set the channel topic. Usage: settopic <topic>
def command_settopic(bot, user, channel, args): "Set the channel topic. Usage: settopic <topic>" if permissions(user) < 10: # 0 public, 1-9 undefined, 10-19 admin, 20 root return bot.say(channel, "{}, insufficient permissions.".format( get_nick(user))) if not args: r...
[ "def", "command_settopic", "(", "bot", ",", "user", ",", "channel", ",", "args", ")", ":", "if", "permissions", "(", "user", ")", "<", "10", ":", "# 0 public, 1-9 undefined, 10-19 admin, 20 root", "return", "bot", ".", "say", "(", "channel", ",", "\"{}, insuff...
[ 262, 0 ]
[ 272, 62 ]
python
en
['en', 'en', 'en']
True
command_join
(bot, user, channel, args)
Usage: join <channel>,... (Comma separated, hash not required).
Usage: join <channel>,... (Comma separated, hash not required).
def command_join(bot, user, channel, args): "Usage: join <channel>,... (Comma separated, hash not required)." if permissions(user) < 10: # 0 public, 1-9 undefined, 10-19 admin, 20 root return bot.say(channel, "{}, insufficient permissions.".format( get_nick(user))) channels...
[ "def", "command_join", "(", "bot", ",", "user", ",", "channel", ",", "args", ")", ":", "if", "permissions", "(", "user", ")", "<", "10", ":", "# 0 public, 1-9 undefined, 10-19 admin, 20 root", "return", "bot", ".", "say", "(", "channel", ",", "\"{}, insufficie...
[ 275, 0 ]
[ 295, 23 ]
python
en
['en', 'en', 'en']
True
command_leave
(bot, user, channel, args)
Usage: leave <channel>,... (Comma separated, hash not required).
Usage: leave <channel>,... (Comma separated, hash not required).
def command_leave(bot, user, channel, args): "Usage: leave <channel>,... (Comma separated, hash not required)." if permissions(user) < 10: # 0 public, 1-9 undefined, 10-19 admin, 20 root return bot.say(channel, "{}, insufficient permissions.".format( get_nick(user))) networ...
[ "def", "command_leave", "(", "bot", ",", "user", ",", "channel", ",", "args", ")", ":", "if", "permissions", "(", "user", ")", "<", "10", ":", "# 0 public, 1-9 undefined, 10-19 admin, 20 root", "return", "bot", ".", "say", "(", "channel", ",", "\"{}, insuffici...
[ 298, 0 ]
[ 328, 75 ]
python
en
['en', 'en', 'en']
True
command_channels
(bot, user, channel, args)
List channels the bot is on.
List channels the bot is on.
def command_channels(bot, user, channel, args): "List channels the bot is on." if permissions(user) < 10: # 0 public, 1-9 undefined, 10-19 admin, 20 root return bot.say(channel, "{}, insufficient permissions.".format( get_nick(user))) return bot.say(channel, "I am on {}" ...
[ "def", "command_channels", "(", "bot", ",", "user", ",", "channel", ",", "args", ")", ":", "if", "permissions", "(", "user", ")", "<", "10", ":", "# 0 public, 1-9 undefined, 10-19 admin, 20 root", "return", "bot", ".", "say", "(", "channel", ",", "\"{}, insuff...
[ 331, 0 ]
[ 338, 71 ]
python
en
['en', 'en', 'en']
True
command_help
(bot, user, channel, cmnd)
Get help on all commands or a specific one. Usage: help [<command>]
Get help on all commands or a specific one. Usage: help [<command>]
def command_help(bot, user, channel, cmnd): "Get help on all commands or a specific one. Usage: help [<command>]" # TODO: Only print commands that are available to the user. commands = [] for module, env in bot.factory.ns.items(): myglobals, mylocals = env commands += [(c.replace("comman...
[ "def", "command_help", "(", "bot", ",", "user", ",", "channel", ",", "cmnd", ")", ":", "# TODO: Only print commands that are available to the user.", "commands", "=", "[", "]", "for", "module", ",", "env", "in", "bot", ".", "factory", ".", "ns", ".", "items", ...
[ 341, 0 ]
[ 359, 70 ]
python
en
['en', 'en', 'en']
True
command_logs
(bot, user, channel, args)
Usage: logs [on|off|level].
Usage: logs [on|off|level].
def command_logs(bot, user, channel, args): "Usage: logs [on|off|level]." if permissions(user) < 20: return bot.say(channel, "{}, insufficient permissions.".format( get_nick(user))) if args == "off" and bot.factory.logs_enabled: bot.factory.logs_enabled = False ...
[ "def", "command_logs", "(", "bot", ",", "user", ",", "channel", ",", "args", ")", ":", "if", "permissions", "(", "user", ")", "<", "20", ":", "return", "bot", ".", "say", "(", "channel", ",", "\"{}, insufficient permissions.\"", ".", "format", "(", "get_...
[ 362, 0 ]
[ 395, 34 ]
python
en
['en', 'en', 'en']
True
command_me
(bot, user, channel, args)
Displays information about the user.
Displays information about the user.
def command_me(bot, user, channel, args): "Displays information about the user." nick = get_nick(user) perms = permissions(user) return bot.say(channel, "{}, your permission level is {}.".format(nick, perms))
[ "def", "command_me", "(", "bot", ",", "user", ",", "channel", ",", "args", ")", ":", "nick", "=", "get_nick", "(", "user", ")", "perms", "=", "permissions", "(", "user", ")", "return", "bot", ".", "say", "(", "channel", ",", "\"{}, your permission level ...
[ 398, 0 ]
[ 403, 77 ]
python
en
['en', 'en', 'en']
True
command_version
(bot, user, channel, args)
Displays the current bot version.
Displays the current bot version.
def command_version(bot, user, channel, args): "Displays the current bot version." return bot.say(channel, "demibot v{} ({})".format(bot.factory.VERSION, bot.factory.URL))
[ "def", "command_version", "(", "bot", ",", "user", ",", "channel", ",", "args", ")", ":", "return", "bot", ".", "say", "(", "channel", ",", "\"demibot v{} ({})\"", ".", "format", "(", "bot", ".", "factory", ".", "VERSION", ",", "bot", ".", "factory", "...
[ 406, 0 ]
[ 409, 71 ]
python
en
['en', 'en', 'en']
True
command_setvar
(bot, user, channel, args)
Change internal variables. Use with extreme caution. Can break the bot. Usage: setvar <var>.
Change internal variables. Use with extreme caution. Can break the bot. Usage: setvar <var>.
def command_setvar(bot, user, channel, args): """Change internal variables. Use with extreme caution. Can break the bot. Usage: setvar <var>.""" perms, nick = permissions(user), get_nick(user) if perms < 20: # 0 public, 1-9 undefined, 10-19 admin, 20 root return bot.say(channel, "{}, insufficie...
[ "def", "command_setvar", "(", "bot", ",", "user", ",", "channel", ",", "args", ")", ":", "perms", ",", "nick", "=", "permissions", "(", "user", ")", ",", "get_nick", "(", "user", ")", "if", "perms", "<", "20", ":", "# 0 public, 1-9 undefined, 10-19 admin, ...
[ 412, 0 ]
[ 449, 37 ]
python
en
['en', 'en', 'en']
True
command_printvars
(bot, user, channel, args)
Prints out crucial variables. Usage: printvars [<var>].
Prints out crucial variables. Usage: printvars [<var>].
def command_printvars(bot, user, channel, args): "Prints out crucial variables. Usage: printvars [<var>]." f = bot.factory perms, nick = permissions(user), get_nick(user) if perms < 20: # 0 public, 1-9 undefined, 10-19 admin, 20 root return bot.say(channel, "{}, insufficient permissions.".forma...
[ "def", "command_printvars", "(", "bot", ",", "user", ",", "channel", ",", "args", ")", ":", "f", "=", "bot", ".", "factory", "perms", ",", "nick", "=", "permissions", "(", "user", ")", ",", "get_nick", "(", "user", ")", "if", "perms", "<", "20", ":...
[ 452, 0 ]
[ 486, 80 ]
python
en
['en', 'af', 'en']
True
command_ping
(bot, user, channel, args)
Dummy command. Try it!
Dummy command. Try it!
def command_ping(bot, user, channel, args): "Dummy command. Try it!" return bot.say(channel, "{}, Pong.".format(get_nick(user)))
[ "def", "command_ping", "(", "bot", ",", "user", ",", "channel", ",", "args", ")", ":", "return", "bot", ".", "say", "(", "channel", ",", "\"{}, Pong.\"", ".", "format", "(", "get_nick", "(", "user", ")", ")", ")" ]
[ 489, 0 ]
[ 491, 63 ]
python
en
['en', 'en', 'en']
True
process_row
(bq_row)
Convert bq_row into dictionary and replace identifiers to nominal values Args: bq_row: BigQuery row Returns: dictionary
Convert bq_row into dictionary and replace identifiers to nominal values
def process_row(bq_row): """ Convert bq_row into dictionary and replace identifiers to nominal values Args: bq_row: BigQuery row Returns: dictionary """ # modify opaque numeric race code into human-readable data races = dict(zip([1, 2, 3, 4, 5, 6, 7, 18, 28, 39, 48], ...
[ "def", "process_row", "(", "bq_row", ")", ":", "# modify opaque numeric race code into human-readable data", "races", "=", "dict", "(", "zip", "(", "[", "1", ",", "2", ",", "3", ",", "4", ",", "5", ",", "6", ",", "7", ",", "18", ",", "28", ",", "39", ...
[ 51, 0 ]
[ 85, 19 ]
python
en
['en', 'error', 'th']
False
to_json_line
(bq_row)
Convert bq_row into json and replace identifiers to nominal values Args: bq_row: BigQuery row Returns: dictionary
Convert bq_row into json and replace identifiers to nominal values
def to_json_line(bq_row): """ Convert bq_row into json and replace identifiers to nominal values Args: bq_row: BigQuery row Returns: dictionary """ # modify opaque numeric race code into human-readable data races = dict(zip([1, 2, 3, 4, 5, 6, 7, 18, 28, 39, 48], ...
[ "def", "to_json_line", "(", "bq_row", ")", ":", "# modify opaque numeric race code into human-readable data", "races", "=", "dict", "(", "zip", "(", "[", "1", ",", "2", ",", "3", ",", "4", ",", "5", ",", "6", ",", "7", ",", "18", ",", "28", ",", "39", ...
[ 88, 0 ]
[ 121, 31 ]
python
en
['en', 'error', 'th']
False
estimate
(instance, inference_type)
Estimate the baby weight given an instance If inference type is 'cmle', the model API deployed on Coud ML Engine is called, otherwise, the local model is called Agrs: instance: dictionary of values representing the input features of the instance inference_type: cane be 'local or 'cmle'...
Estimate the baby weight given an instance If inference type is 'cmle', the model API deployed on Coud ML Engine is called, otherwise, the local model is called
def estimate(instance, inference_type): """ Estimate the baby weight given an instance If inference type is 'cmle', the model API deployed on Coud ML Engine is called, otherwise, the local model is called Agrs: instance: dictionary of values representing the input features of the instance ...
[ "def", "estimate", "(", "instance", ",", "inference_type", ")", ":", "# pop the actual weight if exists", "weight_pounds", "=", "instance", ".", "pop", "(", "'weight_pounds'", ",", "'NA'", ")", "if", "inference_type", "==", "'local'", ":", "estimated_weights", "=", ...
[ 124, 0 ]
[ 150, 19 ]
python
en
['en', 'error', 'th']
False
to_csv
(instance)
Convert the instance, including the estimated baby weight, to csv string Args: instance: dictionary of instance feature values and estimated target Returns: string: comma separated values
Convert the instance, including the estimated baby weight, to csv string
def to_csv(instance): """ Convert the instance, including the estimated baby weight, to csv string Args: instance: dictionary of instance feature values and estimated target Returns: string: comma separated values """ csv_row = ','.join([str(instance[k]) for k in HEADER]) c...
[ "def", "to_csv", "(", "instance", ")", ":", "csv_row", "=", "','", ".", "join", "(", "[", "str", "(", "instance", "[", "k", "]", ")", "for", "k", "in", "HEADER", "]", ")", "csv_row", "+=", "',{}'", ".", "format", "(", "instance", "[", "'estimated_w...
[ 153, 0 ]
[ 165, 18 ]
python
en
['en', 'error', 'th']
False
path_to_url
(path)
Convert a path to a file: URL. The path will be made absolute and have quoted path parts.
Convert a path to a file: URL. The path will be made absolute and have quoted path parts.
def path_to_url(path): # type: (str) -> str """ Convert a path to a file: URL. The path will be made absolute and have quoted path parts. """ path = os.path.normpath(os.path.abspath(path)) url = urllib.parse.urljoin("file:", urllib.request.pathname2url(path)) return url
[ "def", "path_to_url", "(", "path", ")", ":", "# type: (str) -> str", "path", "=", "os", ".", "path", ".", "normpath", "(", "os", ".", "path", ".", "abspath", "(", "path", ")", ")", "url", "=", "urllib", ".", "parse", ".", "urljoin", "(", "\"file:\"", ...
[ 16, 0 ]
[ 24, 14 ]
python
en
['en', 'error', 'th']
False
url_to_path
(url)
Convert a file: URL to a path.
Convert a file: URL to a path.
def url_to_path(url): # type: (str) -> str """ Convert a file: URL to a path. """ assert url.startswith( "file:" ), f"You can only turn file: urls into filenames (not {url!r})" _, netloc, path, _, _ = urllib.parse.urlsplit(url) if not netloc or netloc == "localhost": # ...
[ "def", "url_to_path", "(", "url", ")", ":", "# type: (str) -> str", "assert", "url", ".", "startswith", "(", "\"file:\"", ")", ",", "f\"You can only turn file: urls into filenames (not {url!r})\"", "_", ",", "netloc", ",", "path", ",", "_", ",", "_", "=", "urllib"...
[ 27, 0 ]
[ 64, 15 ]
python
en
['en', 'error', 'th']
False
CartServiceStub.__init__
(self, channel)
Constructor. Args: channel: A grpc.Channel.
Constructor.
def __init__(self, channel): """Constructor. Args: channel: A grpc.Channel. """ self.AddItem = channel.unary_unary( '/hipstershop.CartService/AddItem', request_serializer=demo__pb2.AddItemRequest.SerializeToString, response_deserializer=demo__pb2.Empty.FromString, ...
[ "def", "__init__", "(", "self", ",", "channel", ")", ":", "self", ".", "AddItem", "=", "channel", ".", "unary_unary", "(", "'/hipstershop.CartService/AddItem'", ",", "request_serializer", "=", "demo__pb2", ".", "AddItemRequest", ".", "SerializeToString", ",", "res...
[ 27, 2 ]
[ 47, 9 ]
python
en
['en', 'en', 'en']
False
RecommendationServiceStub.__init__
(self, channel)
Constructor. Args: channel: A grpc.Channel.
Constructor.
def __init__(self, channel): """Constructor. Args: channel: A grpc.Channel. """ self.ListRecommendations = channel.unary_unary( '/hipstershop.RecommendationService/ListRecommendations', request_serializer=demo__pb2.ListRecommendationsRequest.SerializeToString, response_des...
[ "def", "__init__", "(", "self", ",", "channel", ")", ":", "self", ".", "ListRecommendations", "=", "channel", ".", "unary_unary", "(", "'/hipstershop.RecommendationService/ListRecommendations'", ",", "request_serializer", "=", "demo__pb2", ".", "ListRecommendationsRequest...
[ 105, 2 ]
[ 115, 9 ]
python
en
['en', 'en', 'en']
False
ProductCatalogServiceStub.__init__
(self, channel)
Constructor. Args: channel: A grpc.Channel.
Constructor.
def __init__(self, channel): """Constructor. Args: channel: A grpc.Channel. """ self.ListProducts = channel.unary_unary( '/hipstershop.ProductCatalogService/ListProducts', request_serializer=demo__pb2.Empty.SerializeToString, response_deserializer=demo__pb2.ListProductsRes...
[ "def", "__init__", "(", "self", ",", "channel", ")", ":", "self", ".", "ListProducts", "=", "channel", ".", "unary_unary", "(", "'/hipstershop.ProductCatalogService/ListProducts'", ",", "request_serializer", "=", "demo__pb2", ".", "Empty", ".", "SerializeToString", ...
[ 149, 2 ]
[ 169, 9 ]
python
en
['en', 'en', 'en']
False
ShippingServiceStub.__init__
(self, channel)
Constructor. Args: channel: A grpc.Channel.
Constructor.
def __init__(self, channel): """Constructor. Args: channel: A grpc.Channel. """ self.GetQuote = channel.unary_unary( '/hipstershop.ShippingService/GetQuote', request_serializer=demo__pb2.GetQuoteRequest.SerializeToString, response_deserializer=demo__pb2.GetQuoteResponse.Fr...
[ "def", "__init__", "(", "self", ",", "channel", ")", ":", "self", ".", "GetQuote", "=", "channel", ".", "unary_unary", "(", "'/hipstershop.ShippingService/GetQuote'", ",", "request_serializer", "=", "demo__pb2", ".", "GetQuoteRequest", ".", "SerializeToString", ",",...
[ 227, 2 ]
[ 242, 9 ]
python
en
['en', 'en', 'en']
False
CurrencyServiceStub.__init__
(self, channel)
Constructor. Args: channel: A grpc.Channel.
Constructor.
def __init__(self, channel): """Constructor. Args: channel: A grpc.Channel. """ self.GetSupportedCurrencies = channel.unary_unary( '/hipstershop.CurrencyService/GetSupportedCurrencies', request_serializer=demo__pb2.Empty.SerializeToString, response_deserializer=demo__pb2.G...
[ "def", "__init__", "(", "self", ",", "channel", ")", ":", "self", ".", "GetSupportedCurrencies", "=", "channel", ".", "unary_unary", "(", "'/hipstershop.CurrencyService/GetSupportedCurrencies'", ",", "request_serializer", "=", "demo__pb2", ".", "Empty", ".", "Serializ...
[ 288, 2 ]
[ 303, 9 ]
python
en
['en', 'en', 'en']
False
PaymentServiceStub.__init__
(self, channel)
Constructor. Args: channel: A grpc.Channel.
Constructor.
def __init__(self, channel): """Constructor. Args: channel: A grpc.Channel. """ self.Charge = channel.unary_unary( '/hipstershop.PaymentService/Charge', request_serializer=demo__pb2.ChargeRequest.SerializeToString, response_deserializer=demo__pb2.ChargeResponse.FromString,...
[ "def", "__init__", "(", "self", ",", "channel", ")", ":", "self", ".", "Charge", "=", "channel", ".", "unary_unary", "(", "'/hipstershop.PaymentService/Charge'", ",", "request_serializer", "=", "demo__pb2", ".", "ChargeRequest", ".", "SerializeToString", ",", "res...
[ 349, 2 ]
[ 359, 9 ]
python
en
['en', 'en', 'en']
False
EmailServiceStub.__init__
(self, channel)
Constructor. Args: channel: A grpc.Channel.
Constructor.
def __init__(self, channel): """Constructor. Args: channel: A grpc.Channel. """ self.SendOrderConfirmation = channel.unary_unary( '/hipstershop.EmailService/SendOrderConfirmation', request_serializer=demo__pb2.SendOrderConfirmationRequest.SerializeToString, response_deseri...
[ "def", "__init__", "(", "self", ",", "channel", ")", ":", "self", ".", "SendOrderConfirmation", "=", "channel", ".", "unary_unary", "(", "'/hipstershop.EmailService/SendOrderConfirmation'", ",", "request_serializer", "=", "demo__pb2", ".", "SendOrderConfirmationRequest", ...
[ 393, 2 ]
[ 403, 9 ]
python
en
['en', 'en', 'en']
False
CheckoutServiceStub.__init__
(self, channel)
Constructor. Args: channel: A grpc.Channel.
Constructor.
def __init__(self, channel): """Constructor. Args: channel: A grpc.Channel. """ self.CreateOrder = channel.unary_unary( '/hipstershop.CheckoutService/CreateOrder', request_serializer=demo__pb2.CreateOrderRequest.SerializeToString, response_deserializer=demo__pb2.CreateOrde...
[ "def", "__init__", "(", "self", ",", "channel", ")", ":", "self", ".", "CreateOrder", "=", "channel", ".", "unary_unary", "(", "'/hipstershop.CheckoutService/CreateOrder'", ",", "request_serializer", "=", "demo__pb2", ".", "CreateOrderRequest", ".", "SerializeToString...
[ 437, 2 ]
[ 452, 9 ]
python
en
['en', 'en', 'en']
False
decode_dxt1
(data, alpha=False)
input: one "row" of data (i.e. will produce 4*width pixels)
input: one "row" of data (i.e. will produce 4*width pixels)
def decode_dxt1(data, alpha=False): """ input: one "row" of data (i.e. will produce 4*width pixels) """ blocks = len(data) // 8 # number of blocks in row ret = (bytearray(), bytearray(), bytearray(), bytearray()) for block in range(blocks): # Decode next 8-byte block. idx = bl...
[ "def", "decode_dxt1", "(", "data", ",", "alpha", "=", "False", ")", ":", "blocks", "=", "len", "(", "data", ")", "//", "8", "# number of blocks in row", "ret", "=", "(", "bytearray", "(", ")", ",", "bytearray", "(", ")", ",", "bytearray", "(", ")", "...
[ 51, 0 ]
[ 103, 14 ]
python
en
['en', 'error', 'th']
False
decode_dxt3
(data)
input: one "row" of data (i.e. will produce 4*width pixels)
input: one "row" of data (i.e. will produce 4*width pixels)
def decode_dxt3(data): """ input: one "row" of data (i.e. will produce 4*width pixels) """ blocks = len(data) // 16 # number of blocks in row ret = (bytearray(), bytearray(), bytearray(), bytearray()) for block in range(blocks): idx = block * 16 block = data[idx : idx + 16] ...
[ "def", "decode_dxt3", "(", "data", ")", ":", "blocks", "=", "len", "(", "data", ")", "//", "16", "# number of blocks in row", "ret", "=", "(", "bytearray", "(", ")", ",", "bytearray", "(", ")", ",", "bytearray", "(", ")", ",", "bytearray", "(", ")", ...
[ 106, 0 ]
[ 156, 14 ]
python
en
['en', 'error', 'th']
False
decode_dxt5
(data)
input: one "row" of data (i.e. will produce 4 * width pixels)
input: one "row" of data (i.e. will produce 4 * width pixels)
def decode_dxt5(data): """ input: one "row" of data (i.e. will produce 4 * width pixels) """ blocks = len(data) // 16 # number of blocks in row ret = (bytearray(), bytearray(), bytearray(), bytearray()) for block in range(blocks): idx = block * 16 block = data[idx : idx + 16] ...
[ "def", "decode_dxt5", "(", "data", ")", ":", "blocks", "=", "len", "(", "data", ")", "//", "16", "# number of blocks in row", "ret", "=", "(", "bytearray", "(", ")", ",", "bytearray", "(", ")", ",", "bytearray", "(", ")", ",", "bytearray", "(", ")", ...
[ 159, 0 ]
[ 226, 14 ]
python
en
['en', 'error', 'th']
False
AppEngineAdminHook.get_ae_conn
(self)
Returns: a App Engine service object.
Returns: a App Engine service object.
def get_ae_conn(self): """Returns: a App Engine service object.""" credentials = GoogleCredentials.get_application_default() return build('appengine', 'v1', credentials=credentials)
[ "def", "get_ae_conn", "(", "self", ")", ":", "credentials", "=", "GoogleCredentials", ".", "get_application_default", "(", ")", "return", "build", "(", "'appengine'", ",", "'v1'", ",", "credentials", "=", "credentials", ")" ]
[ 38, 2 ]
[ 41, 60 ]
python
en
['en', 'en', 'en']
True
AppEngineAdminHook.get_svc_conn
(self)
Returns: a Services Management service object.
Returns: a Services Management service object.
def get_svc_conn(self): """Returns: a Services Management service object.""" credentials = GoogleCredentials.get_application_default() return build('servicemanagement', 'v1', credentials=credentials)
[ "def", "get_svc_conn", "(", "self", ")", ":", "credentials", "=", "GoogleCredentials", ".", "get_application_default", "(", ")", "return", "build", "(", "'servicemanagement'", ",", "'v1'", ",", "credentials", "=", "credentials", ")" ]
[ 43, 2 ]
[ 46, 68 ]
python
en
['en', 'fr', 'en']
True
AppEngineAdminHook.create_version
(self, project_id, service_id, version_spec)
Creates new service version on App Engine Engine. Args: project_id: project id service_id: service id version_spec: app version spec Returns: The operation if the version was created successfully and raises an error otherwise.
Creates new service version on App Engine Engine.
def create_version(self, project_id, service_id, version_spec): """Creates new service version on App Engine Engine. Args: project_id: project id service_id: service id version_spec: app version spec Returns: The operation if the version was created successfully and raises an...
[ "def", "create_version", "(", "self", ",", "project_id", ",", "service_id", ",", "version_spec", ")", ":", "create_request", "=", "self", ".", "_gaeadmin", ".", "apps", "(", ")", ".", "services", "(", ")", ".", "versions", "(", ")", ".", "create", "(", ...
[ 48, 2 ]
[ 64, 61 ]
python
en
['en', 'ja', 'en']
True
AppEngineAdminHook.migrate_traffic
(self, project_id, service_id, new_version)
Migrate AE traffic from current version to new version. Args: project_id: project id service_id: service id new_version: new version id Returns: the operation if the migration was successful and raises an error otherwise.
Migrate AE traffic from current version to new version.
def migrate_traffic(self, project_id, service_id, new_version): """Migrate AE traffic from current version to new version. Args: project_id: project id service_id: service id new_version: new version id Returns: the operation if the migration was successful and raises an erro...
[ "def", "migrate_traffic", "(", "self", ",", "project_id", ",", "service_id", ",", "new_version", ")", ":", "split_config", "=", "{", "'split'", ":", "{", "'allocations'", ":", "{", "new_version", ":", "'1'", "}", "}", "}", "migrate_request", "=", "self", "...
[ 66, 2 ]
[ 84, 61 ]
python
en
['en', 'en', 'en']
True
AppEngineAdminHook.get_endpoint_config
(self, service_id)
Get latest endpoint config for an endpoint service. Args: service_id: service id Returns: the config version if successful and raises an error otherwise.
Get latest endpoint config for an endpoint service.
def get_endpoint_config(self, service_id): """Get latest endpoint config for an endpoint service. Args: service_id: service id Returns: the config version if successful and raises an error otherwise. """ resource = self._svcadmin.services().rollouts() list_request = resource.list(s...
[ "def", "get_endpoint_config", "(", "self", ",", "service_id", ")", ":", "resource", "=", "self", ".", "_svcadmin", ".", "services", "(", ")", ".", "rollouts", "(", ")", "list_request", "=", "resource", ".", "list", "(", "serviceName", "=", "service_id", ")...
[ 86, 2 ]
[ 100, 20 ]
python
en
['en', 'en', 'en']
True
AppEngineAdminHook.get_version
(self, project_id, service_id, version)
Get spec for a version of a service on App Engine Engine. Args: project_id: project id service_id: service id version: version id Returns: the version spec if successful and raises an error otherwise.
Get spec for a version of a service on App Engine Engine.
def get_version(self, project_id, service_id, version): """Get spec for a version of a service on App Engine Engine. Args: project_id: project id service_id: service id version: version id Returns: the version spec if successful and raises an error otherwise. """ resource =...
[ "def", "get_version", "(", "self", ",", "project_id", ",", "service_id", ",", "version", ")", ":", "resource", "=", "self", ".", "_gaeadmin", ".", "apps", "(", ")", ".", "services", "(", ")", ".", "versions", "(", ")", "get_request", "=", "resource", "...
[ 102, 2 ]
[ 118, 19 ]
python
en
['en', 'en', 'en']
True
AppEngineAdminHook.get_version_identifiers
(self, project_id, service_id)
Get list of versions of a service on App Engine Engine. Args: project_id: project id service_id: service id Returns: the list of version identifiers if successful and raises an error otherwise.
Get list of versions of a service on App Engine Engine.
def get_version_identifiers(self, project_id, service_id): """Get list of versions of a service on App Engine Engine. Args: project_id: project id service_id: service id Returns: the list of version identifiers if successful and raises an error otherwise. """ request = self._gaea...
[ "def", "get_version_identifiers", "(", "self", ",", "project_id", ",", "service_id", ")", ":", "request", "=", "self", ".", "_gaeadmin", ".", "apps", "(", ")", ".", "services", "(", ")", ".", "versions", "(", ")", ".", "list", "(", "appsId", "=", "proj...
[ 120, 2 ]
[ 139, 19 ]
python
en
['en', 'en', 'en']
True
AppEngineAdminHook._get_operation
(self, project_id, op_name)
Gets an AppEngine operation based on the operation name. Args: project_id: project id op_name: operation name Returns: AppEngine operation object if succeed. Raises: apiclient.errors.HttpError: if HTTP error is returned from server
Gets an AppEngine operation based on the operation name.
def _get_operation(self, project_id, op_name): """Gets an AppEngine operation based on the operation name. Args: project_id: project id op_name: operation name Returns: AppEngine operation object if succeed. Raises: apiclient.errors.HttpError: if HTTP error is returned from se...
[ "def", "_get_operation", "(", "self", ",", "project_id", ",", "op_name", ")", ":", "resource", "=", "self", ".", "_gaeadmin", ".", "apps", "(", ")", ".", "operations", "(", ")", "request", "=", "resource", ".", "get", "(", "appsId", "=", "project_id", ...
[ 141, 2 ]
[ 156, 28 ]
python
en
['en', 'en', 'en']
True
AppEngineAdminHook._wait_for_operation_done
(self, project_id, op_name, interval=30)
Waits for the Operation to reach a terminal state. This method will periodically check the job state until the operation reaches a terminal state. Args: project_id: project id op_name: operation name interval: check interval in seconds Returns: AppEngine operation object if su...
Waits for the Operation to reach a terminal state.
def _wait_for_operation_done(self, project_id, op_name, interval=30): """Waits for the Operation to reach a terminal state. This method will periodically check the job state until the operation reaches a terminal state. Args: project_id: project id op_name: operation name interval: c...
[ "def", "_wait_for_operation_done", "(", "self", ",", "project_id", ",", "op_name", ",", "interval", "=", "30", ")", ":", "assert", "interval", ">", "0", "while", "True", ":", "operation", "=", "self", ".", "_get_operation", "(", "project_id", ",", "op_name",...
[ 158, 2 ]
[ 181, 26 ]
python
en
['en', 'en', 'en']
True
usage
(**options)
Get account usage details. Get a report on the status of your Cloudinary account usage details, including storage, credits, bandwidth, requests, number of resources, and add-on usage. Note that numbers are updated periodically. See: `Get account usage details <https://cloudinary.com/documentation/admi...
Get account usage details.
def usage(**options): """Get account usage details. Get a report on the status of your Cloudinary account usage details, including storage, credits, bandwidth, requests, number of resources, and add-on usage. Note that numbers are updated periodically. See: `Get account usage details <https://clou...
[ "def", "usage", "(", "*", "*", "options", ")", ":", "date", "=", "options", ".", "pop", "(", "\"date\"", ",", "None", ")", "uri", "=", "[", "\"usage\"", "]", "if", "date", ":", "if", "isinstance", "(", "date", ",", "datetime", ".", "date", ")", "...
[ 33, 0 ]
[ 53, 46 ]
python
de
['fr', 'de', 'en']
False
resources_by_context
(key, value=None, **options)
Retrieves resources (assets) with a specified context key. This method does not return deleted assets even if they have been backed up. See: `Get resources by context API reference <https://cloudinary.com/documentation/admin_api#get_resources_by_context>`_ :param key: Only assets with this con...
Retrieves resources (assets) with a specified context key. This method does not return deleted assets even if they have been backed up.
def resources_by_context(key, value=None, **options): """Retrieves resources (assets) with a specified context key. This method does not return deleted assets even if they have been backed up. See: `Get resources by context API reference <https://cloudinary.com/documentation/admin_api#get_resources_by_...
[ "def", "resources_by_context", "(", "key", ",", "value", "=", "None", ",", "*", "*", "options", ")", ":", "resource_type", "=", "options", ".", "pop", "(", "\"resource_type\"", ",", "\"image\"", ")", "uri", "=", "[", "\"resources\"", ",", "resource_type", ...
[ 95, 0 ]
[ 118, 50 ]
python
en
['en', 'en', 'en']
True
delete_derived_by_transformation
(public_ids, transformations, resource_type='image', type='upload', invalidate=None, **options)
Delete derived resources of public ids, identified by transformations :param public_ids: the base resources :type public_ids: list of str :param transformations: the transformation of derived resources, optionally including the format :type transformations: list of (dict or str) :param type: The up...
Delete derived resources of public ids, identified by transformations
def delete_derived_by_transformation(public_ids, transformations, resource_type='image', type='upload', invalidate=None, **options): """Delete derived resources of public ids, identified by transformations :param public_ids: the base res...
[ "def", "delete_derived_by_transformation", "(", "public_ids", ",", "transformations", ",", "resource_type", "=", "'image'", ",", "type", "=", "'upload'", ",", "invalidate", "=", "None", ",", "*", "*", "options", ")", ":", "uri", "=", "[", "\"resources\"", ",",...
[ 194, 0 ]
[ 220, 53 ]
python
en
['en', 'en', 'en']
True
delete_folder
(path, **options)
Deletes folder Deleted folder must be empty, but can have descendant empty sub folders :param path: The folder to delete :param options: Additional options :rtype: Response
Deletes folder
def delete_folder(path, **options): """Deletes folder Deleted folder must be empty, but can have descendant empty sub folders :param path: The folder to delete :param options: Additional options :rtype: Response """ return call_api("delete", ["folders", path], {}, **options)
[ "def", "delete_folder", "(", "path", ",", "*", "*", "options", ")", ":", "return", "call_api", "(", "\"delete\"", ",", "[", "\"folders\"", ",", "path", "]", ",", "{", "}", ",", "*", "*", "options", ")" ]
[ 340, 0 ]
[ 350, 63 ]
python
da
['en', 'da', 'tr']
False
list_metadata_fields
(**options)
Returns a list of all metadata field definitions See: `Get metadata fields API reference <https://cloudinary.com/documentation/admin_api#get_metadata_fields>`_ :param options: Additional options :rtype: Response
Returns a list of all metadata field definitions
def list_metadata_fields(**options): """Returns a list of all metadata field definitions See: `Get metadata fields API reference <https://cloudinary.com/documentation/admin_api#get_metadata_fields>`_ :param options: Additional options :rtype: Response """ return call_metadata_api("get", [], {...
[ "def", "list_metadata_fields", "(", "*", "*", "options", ")", ":", "return", "call_metadata_api", "(", "\"get\"", ",", "[", "]", ",", "{", "}", ",", "*", "*", "options", ")" ]
[ 447, 0 ]
[ 456, 54 ]
python
en
['en', 'lb', 'en']
True
metadata_field_by_field_id
(field_external_id, **options)
Gets a metadata field by external id See: `Get metadata field by external ID API reference <https://cloudinary.com/documentation/admin_api#get_a_metadata_field_by_external_id>`_ :param field_external_id: The ID of the metadata field to retrieve :param options: Additional options :rtype: Response ...
Gets a metadata field by external id
def metadata_field_by_field_id(field_external_id, **options): """Gets a metadata field by external id See: `Get metadata field by external ID API reference <https://cloudinary.com/documentation/admin_api#get_a_metadata_field_by_external_id>`_ :param field_external_id: The ID of the metadata field to r...
[ "def", "metadata_field_by_field_id", "(", "field_external_id", ",", "*", "*", "options", ")", ":", "uri", "=", "[", "field_external_id", "]", "return", "call_metadata_api", "(", "\"get\"", ",", "uri", ",", "{", "}", ",", "*", "*", "options", ")" ]
[ 459, 0 ]
[ 471, 55 ]
python
en
['en', 'lb', 'en']
True
add_metadata_field
(field, **options)
Creates a new metadata field definition See: `Create metadata field API reference <https://cloudinary.com/documentation/admin_api#create_a_metadata_field>`_ :param field: The field to add :param options: Additional options :rtype: Response
Creates a new metadata field definition
def add_metadata_field(field, **options): """Creates a new metadata field definition See: `Create metadata field API reference <https://cloudinary.com/documentation/admin_api#create_a_metadata_field>`_ :param field: The field to add :param options: Additional options :rtype: Response """ ...
[ "def", "add_metadata_field", "(", "field", ",", "*", "*", "options", ")", ":", "params", "=", "only", "(", "field", ",", "\"type\"", ",", "\"external_id\"", ",", "\"label\"", ",", "\"mandatory\"", ",", "\"default_value\"", ",", "\"validation\"", ",", "\"dataso...
[ 474, 0 ]
[ 486, 59 ]
python
en
['en', 'en', 'en']
True
update_metadata_field
(field_external_id, field, **options)
Updates a metadata field by external id Updates a metadata field definition (partially, no need to pass the entire object) passed as JSON data. See `Generic structure of a metadata field <https://cloudinary.com/documentation/admin_api#generic_structure_of_a_metadata_field>`_ for details. :param f...
Updates a metadata field by external id
def update_metadata_field(field_external_id, field, **options): """Updates a metadata field by external id Updates a metadata field definition (partially, no need to pass the entire object) passed as JSON data. See `Generic structure of a metadata field <https://cloudinary.com/documentation/admin_...
[ "def", "update_metadata_field", "(", "field_external_id", ",", "field", ",", "*", "*", "options", ")", ":", "uri", "=", "[", "field_external_id", "]", "params", "=", "only", "(", "field", ",", "\"label\"", ",", "\"mandatory\"", ",", "\"default_value\"", ",", ...
[ 489, 0 ]
[ 506, 59 ]
python
en
['en', 'lb', 'en']
True
delete_metadata_field
(field_external_id, **options)
Deletes a metadata field definition. The field should no longer be considered a valid candidate for all other endpoints See: `Delete metadata field API reference <https://cloudinary.com/documentation/admin_api#delete_a_metadata_field_by_external_id>`_ :param field_external_id: The external id of the f...
Deletes a metadata field definition. The field should no longer be considered a valid candidate for all other endpoints
def delete_metadata_field(field_external_id, **options): """Deletes a metadata field definition. The field should no longer be considered a valid candidate for all other endpoints See: `Delete metadata field API reference <https://cloudinary.com/documentation/admin_api#delete_a_metadata_field_by_extern...
[ "def", "delete_metadata_field", "(", "field_external_id", ",", "*", "*", "options", ")", ":", "uri", "=", "[", "field_external_id", "]", "return", "call_metadata_api", "(", "\"delete\"", ",", "uri", ",", "{", "}", ",", "*", "*", "options", ")" ]
[ 509, 0 ]
[ 523, 58 ]
python
en
['en', 'en', 'en']
True
delete_datasource_entries
(field_external_id, entries_external_id, **options)
Deletes entries in a metadata field datasource Deletes (blocks) the datasource entries for a specified metadata field definition. Sets the state of the entries to inactive. This is a soft delete, the entries still exist under the hood and can be activated again with the restore datasource entries metho...
Deletes entries in a metadata field datasource
def delete_datasource_entries(field_external_id, entries_external_id, **options): """Deletes entries in a metadata field datasource Deletes (blocks) the datasource entries for a specified metadata field definition. Sets the state of the entries to inactive. This is a soft delete, the entries still exis...
[ "def", "delete_datasource_entries", "(", "field_external_id", ",", "entries_external_id", ",", "*", "*", "options", ")", ":", "uri", "=", "[", "field_external_id", ",", "\"datasource\"", "]", "params", "=", "{", "\"external_ids\"", ":", "entries_external_id", "}", ...
[ 526, 0 ]
[ 546, 62 ]
python
en
['en', 'en', 'nl']
True
update_metadata_field_datasource
(field_external_id, entries_external_id, **options)
Updates a metadata field datasource Updates the datasource of a supported field type (currently only enum and set), passed as JSON data. The update is partial: datasource entries with an existing external_id will be updated and entries with new external_id's (or without external_id's) will be appended....
Updates a metadata field datasource
def update_metadata_field_datasource(field_external_id, entries_external_id, **options): """Updates a metadata field datasource Updates the datasource of a supported field type (currently only enum and set), passed as JSON data. The update is partial: datasource entries with an existing external_id wil...
[ "def", "update_metadata_field_datasource", "(", "field_external_id", ",", "entries_external_id", ",", "*", "*", "options", ")", ":", "values", "=", "[", "]", "for", "item", "in", "entries_external_id", ":", "external", "=", "only", "(", "item", ",", "\"external_...
[ 549, 0 ]
[ 574, 59 ]
python
en
['en', 'lb', 'en']
True
restore_metadata_field_datasource
(field_external_id, entries_external_ids, **options)
Restores entries in a metadata field datasource Restores (unblocks) any previously deleted datasource entries for a specified metadata field definition. Sets the state of the entries to active. See: `Restore entries in a metadata field datasource API reference <https://cloudinary.com/documentation...
Restores entries in a metadata field datasource
def restore_metadata_field_datasource(field_external_id, entries_external_ids, **options): """Restores entries in a metadata field datasource Restores (unblocks) any previously deleted datasource entries for a specified metadata field definition. Sets the state of the entries to active. See: `Rest...
[ "def", "restore_metadata_field_datasource", "(", "field_external_id", ",", "entries_external_ids", ",", "*", "*", "options", ")", ":", "uri", "=", "[", "field_external_id", ",", "'datasource_restore'", "]", "params", "=", "{", "\"external_ids\"", ":", "entries_externa...
[ 577, 0 ]
[ 596, 60 ]
python
en
['en', 'de', 'en']
True
build_wheel
(source_dir, wheel_dir, config_settings=None)
Build a wheel from a source directory using PEP 517 hooks. :param str source_dir: Source directory containing pyproject.toml :param str wheel_dir: Target directory to create wheel in :param dict config_settings: Options to pass to build backend This is a blocking function which will run pip in a subpr...
Build a wheel from a source directory using PEP 517 hooks.
def build_wheel(source_dir, wheel_dir, config_settings=None): """Build a wheel from a source directory using PEP 517 hooks. :param str source_dir: Source directory containing pyproject.toml :param str wheel_dir: Target directory to create wheel in :param dict config_settings: Options to pass to build b...
[ "def", "build_wheel", "(", "source_dir", ",", "wheel_dir", ",", "config_settings", "=", "None", ")", ":", "if", "config_settings", "is", "None", ":", "config_settings", "=", "{", "}", "requires", ",", "backend", ",", "backend_path", "=", "_load_pyproject", "("...
[ 129, 0 ]
[ 148, 60 ]
python
en
['en', 'en', 'en']
True
build_sdist
(source_dir, sdist_dir, config_settings=None)
Build an sdist from a source directory using PEP 517 hooks. :param str source_dir: Source directory containing pyproject.toml :param str sdist_dir: Target directory to place sdist in :param dict config_settings: Options to pass to build backend This is a blocking function which will run pip in a subpr...
Build an sdist from a source directory using PEP 517 hooks.
def build_sdist(source_dir, sdist_dir, config_settings=None): """Build an sdist from a source directory using PEP 517 hooks. :param str source_dir: Source directory containing pyproject.toml :param str sdist_dir: Target directory to place sdist in :param dict config_settings: Options to pass to build b...
[ "def", "build_sdist", "(", "source_dir", ",", "sdist_dir", ",", "config_settings", "=", "None", ")", ":", "if", "config_settings", "is", "None", ":", "config_settings", "=", "{", "}", "requires", ",", "backend", ",", "backend_path", "=", "_load_pyproject", "("...
[ 151, 0 ]
[ 170, 60 ]
python
en
['en', 'en', 'en']
True
BuildEnvironment.pip_install
(self, reqs)
Install dependencies into this env by calling pip in a subprocess
Install dependencies into this env by calling pip in a subprocess
def pip_install(self, reqs): """Install dependencies into this env by calling pip in a subprocess""" if not reqs: return log.info('Calling pip to install %s', reqs) cmd = [ sys.executable, '-m', 'pip', 'install', '--ignore-installed', '--prefix', self....
[ "def", "pip_install", "(", "self", ",", "reqs", ")", ":", "if", "not", "reqs", ":", "return", "log", ".", "info", "(", "'Calling pip to install %s'", ",", "reqs", ")", "cmd", "=", "[", "sys", ".", "executable", ",", "'-m'", ",", "'pip'", ",", "'install...
[ 95, 4 ]
[ 107, 9 ]
python
en
['en', 'en', 'en']
True
publish_feedback
(feedback)
pull_feedback Starts pulling messages from subscription - receive callback function from calling module - initiate the pull providing the callback function
pull_feedback
def publish_feedback(feedback): # TODO: Publish the feedback object to the feedback topic # END TODO """pull_feedback Starts pulling messages from subscription - receive callback function from calling module - initiate the pull providing the callback function """
[ "def", "publish_feedback", "(", "feedback", ")", ":", "# TODO: Publish the feedback object to the feedback topic", "# END TODO" ]
[ 58, 0 ]
[ 71, 3 ]
python
en
['en', 'cy', 'en']
False
generate_token
(key, user_id, action_id='', when=None)
Generates a URL-safe token for the given user, action, time tuple. Args: key: secret key to use. user_id: the user ID of the authenticated user. action_id: a string identifier of the action they requested authorization for. when: the time in seconds since the epoc...
Generates a URL-safe token for the given user, action, time tuple.
def generate_token(key, user_id, action_id='', when=None): """Generates a URL-safe token for the given user, action, time tuple. Args: key: secret key to use. user_id: the user ID of the authenticated user. action_id: a string identifier of the action they requested a...
[ "def", "generate_token", "(", "key", ",", "user_id", ",", "action_id", "=", "''", ",", "when", "=", "None", ")", ":", "digester", "=", "hmac", ".", "new", "(", "_helpers", ".", "_to_bytes", "(", "key", ",", "encoding", "=", "'utf-8'", ")", ")", "dige...
[ 32, 0 ]
[ 56, 16 ]
python
en
['en', 'en', 'en']
True
validate_token
(key, token, user_id, action_id="", current_time=None)
Validates that the given token authorizes the user for the action. Tokens are invalid if the time of issue is too old or if the token does not match what generateToken outputs (i.e. the token was forged). Args: key: secret key to use. token: a string of the token generated by generateToken...
Validates that the given token authorizes the user for the action.
def validate_token(key, token, user_id, action_id="", current_time=None): """Validates that the given token authorizes the user for the action. Tokens are invalid if the time of issue is too old or if the token does not match what generateToken outputs (i.e. the token was forged). Args: key: s...
[ "def", "validate_token", "(", "key", ",", "token", ",", "user_id", ",", "action_id", "=", "\"\"", ",", "current_time", "=", "None", ")", ":", "if", "not", "token", ":", "return", "False", "try", ":", "decoded", "=", "base64", ".", "urlsafe_b64decode", "(...
[ 60, 0 ]
[ 100, 24 ]
python
en
['en', 'en', 'en']
True
filesys_decode
(path)
Ensure that the given path is decoded, NONE when no expected encoding works
Ensure that the given path is decoded, NONE when no expected encoding works
def filesys_decode(path): """ Ensure that the given path is decoded, NONE when no expected encoding works """ if isinstance(path, six.text_type): return path fs_enc = sys.getfilesystemencoding() or 'utf-8' candidates = fs_enc, 'utf-8' for enc in candidates: try: ...
[ "def", "filesys_decode", "(", "path", ")", ":", "if", "isinstance", "(", "path", ",", "six", ".", "text_type", ")", ":", "return", "path", "fs_enc", "=", "sys", ".", "getfilesystemencoding", "(", ")", "or", "'utf-8'", "candidates", "=", "fs_enc", ",", "'...
[ 19, 0 ]
[ 35, 20 ]
python
en
['en', 'error', 'th']
False
try_encode
(string, enc)
turn unicode encoding into a functional routine
turn unicode encoding into a functional routine
def try_encode(string, enc): "turn unicode encoding into a functional routine" try: return string.encode(enc) except UnicodeEncodeError: return None
[ "def", "try_encode", "(", "string", ",", "enc", ")", ":", "try", ":", "return", "string", ".", "encode", "(", "enc", ")", "except", "UnicodeEncodeError", ":", "return", "None" ]
[ 38, 0 ]
[ 43, 19 ]
python
en
['en', 'en', 'en']
True
SessionStore.create_model_instance
(self, data)
Return a new instance of the session model object, which represents the current session state. Intended to be used for saving the session data to the database.
Return a new instance of the session model object, which represents the current session state. Intended to be used for saving the session data to the database.
def create_model_instance(self, data): """ Return a new instance of the session model object, which represents the current session state. Intended to be used for saving the session data to the database. """ return self.model( session_key=self._get_or_create_se...
[ "def", "create_model_instance", "(", "self", ",", "data", ")", ":", "return", "self", ".", "model", "(", "session_key", "=", "self", ".", "_get_or_create_session_key", "(", ")", ",", "session_data", "=", "self", ".", "encode", "(", "data", ")", ",", "expir...
[ 61, 4 ]
[ 71, 9 ]
python
en
['en', 'error', 'th']
False
SessionStore.save
(self, must_create=False)
Save the current session data to the database. If 'must_create' is True, raise a database error if the saving operation doesn't create a new entry (as opposed to possibly updating an existing entry).
Save the current session data to the database. If 'must_create' is True, raise a database error if the saving operation doesn't create a new entry (as opposed to possibly updating an existing entry).
def save(self, must_create=False): """ Save the current session data to the database. If 'must_create' is True, raise a database error if the saving operation doesn't create a new entry (as opposed to possibly updating an existing entry). """ if self.session_key is None: ...
[ "def", "save", "(", "self", ",", "must_create", "=", "False", ")", ":", "if", "self", ".", "session_key", "is", "None", ":", "return", "self", ".", "create", "(", ")", "data", "=", "self", ".", "_get_session", "(", "no_load", "=", "must_create", ")", ...
[ 73, 4 ]
[ 94, 17 ]
python
en
['en', 'error', 'th']
False
MonoRandomForestClassifier.predict
(self, X)
Predict class for X. NOTE: We need to override parent method's predict() so we can allow for Kotlowski and Slowinski style monotone ensembling. The predicted class of an input sample is a vote by the trees in the forest, weighted by their probability estimates. That is, the pre...
Predict class for X.
def predict(self, X): """Predict class for X. NOTE: We need to override parent method's predict() so we can allow for Kotlowski and Slowinski style monotone ensembling. The predicted class of an input sample is a vote by the trees in the forest, weighted by their probability es...
[ "def", "predict", "(", "self", ",", "X", ")", ":", "if", "self", ".", "n_outputs_", "==", "1", ":", "if", "self", ".", "n_classes_", "<=", "2", ":", "proba", "=", "self", ".", "predict_proba", "(", "X", ")", "return", "self", ".", "classes_", ".", ...
[ 304, 4 ]
[ 355, 30 ]
python
en
['en', 'it', 'en']
True
MonoRandomForestClassifier.predict_proba
(self, X)
Predict class probabilities for X. NOTE: We need to override parent method's predict() so we can allow for Kotlowski and Slowinski style monotone ensembling. NOTE: because these probabilities are calculated from the component binary classifiers, sometimes small negative numbers can res...
Predict class probabilities for X.
def predict_proba(self, X): """Predict class probabilities for X. NOTE: We need to override parent method's predict() so we can allow for Kotlowski and Slowinski style monotone ensembling. NOTE: because these probabilities are calculated from the component binary classifiers, s...
[ "def", "predict_proba", "(", "self", ",", "X", ")", ":", "proba", "=", "super", "(", ")", ".", "predict_proba", "(", "X", ")", "# if self.n_classes_ > 2:", "# proba_cum = self.predict_cum_proba(X)", "# proba = np.zeros([X.shape[0], self.n_classes_])", "# for i i...
[ 357, 4 ]
[ 398, 20 ]
python
en
['en', 'en', 'en']
True
MonoRandomForestClassifier.predict_cum_proba
(self, X)
Predict cumulative class probabilities for X. NOTE: This function should be used with care, as it returns the binary classifier ensemble component probabilities: - e.g. for y in {1,2,3,4} the returned probabilities are [P(y>1), P(y>2), P(y>3)] The predicted cl...
Predict cumulative class probabilities for X. NOTE: This function should be used with care, as it returns the binary classifier ensemble component probabilities: - e.g. for y in {1,2,3,4} the returned probabilities are [P(y>1), P(y>2), P(y>3)] The predicted cl...
def predict_cum_proba(self, X): """ Predict cumulative class probabilities for X. NOTE: This function should be used with care, as it returns the binary classifier ensemble component probabilities: - e.g. for y in {1,2,3,4} the returned probabilities are [P(y>1), P(...
[ "def", "predict_cum_proba", "(", "self", ",", "X", ")", ":", "# check_is_fitted(self)", "# Check data", "X", "=", "self", ".", "_validate_X_predict", "(", "X", ")", "# Assign chunk of trees to jobs", "n_jobs", ",", "_", ",", "_", "=", "_partition_estimators", "(",...
[ 400, 4 ]
[ 451, 28 ]
python
en
['en', 'error', 'th']
False
MonoRandomForestClassifier._set_oob_score
(self, X, y)
Compute out-of-bag score
Compute out-of-bag score
def _set_oob_score(self, X, y): """Compute out-of-bag score""" X = check_array(X, dtype=DTYPE, accept_sparse='csr') if self.n_classes_[0] > 2: n_classes_ = list( np.asarray( self.n_classes_) - 1) # CHANGED TO K-1 else: ...
[ "def", "_set_oob_score", "(", "self", ",", "X", ",", "y", ")", ":", "X", "=", "check_array", "(", "X", ",", "dtype", "=", "DTYPE", ",", "accept_sparse", "=", "'csr'", ")", "if", "self", ".", "n_classes_", "[", "0", "]", ">", "2", ":", "n_classes_",...
[ 524, 4 ]
[ 582, 53 ]
python
en
['en', 'en', 'en']
True
make_hashable
(value)
Attempt to make value hashable or raise a TypeError if it fails. The returned value should generate the same hash for equal values.
Attempt to make value hashable or raise a TypeError if it fails.
def make_hashable(value): """ Attempt to make value hashable or raise a TypeError if it fails. The returned value should generate the same hash for equal values. """ if isinstance(value, dict): return tuple([ (key, make_hashable(nested_value)) for key, nested_value i...
[ "def", "make_hashable", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "return", "tuple", "(", "[", "(", "key", ",", "make_hashable", "(", "nested_value", ")", ")", "for", "key", ",", "nested_value", "in", "sorted", "(...
[ 3, 0 ]
[ 23, 16 ]
python
en
['en', 'error', 'th']
False
last_arg_byref
(args)
Return the last C argument's value by reference.
Return the last C argument's value by reference.
def last_arg_byref(args): "Return the last C argument's value by reference." return args[-1]._obj.value
[ "def", "last_arg_byref", "(", "args", ")", ":", "return", "args", "[", "-", "1", "]", ".", "_obj", ".", "value" ]
[ 14, 0 ]
[ 16, 30 ]
python
en
['en', 'en', 'en']
True
check_dbl
(result, func, cargs)
Check the status code and returns the double value passed in by reference.
Check the status code and returns the double value passed in by reference.
def check_dbl(result, func, cargs): "Check the status code and returns the double value passed in by reference." # Checking the status code if result != 1: return None # Double passed in by reference, return its value. return last_arg_byref(cargs)
[ "def", "check_dbl", "(", "result", ",", "func", ",", "cargs", ")", ":", "# Checking the status code", "if", "result", "!=", "1", ":", "return", "None", "# Double passed in by reference, return its value.", "return", "last_arg_byref", "(", "cargs", ")" ]
[ 19, 0 ]
[ 25, 32 ]
python
en
['en', 'en', 'en']
True
check_geom
(result, func, cargs)
Error checking on routines that return Geometries.
Error checking on routines that return Geometries.
def check_geom(result, func, cargs): "Error checking on routines that return Geometries." if not result: raise GEOSException('Error encountered checking Geometry returned from GEOS C function "%s".' % func.__name__) return result
[ "def", "check_geom", "(", "result", ",", "func", ",", "cargs", ")", ":", "if", "not", "result", ":", "raise", "GEOSException", "(", "'Error encountered checking Geometry returned from GEOS C function \"%s\".'", "%", "func", ".", "__name__", ")", "return", "result" ]
[ 28, 0 ]
[ 32, 17 ]
python
en
['en', 'el-Latn', 'en']
True
check_minus_one
(result, func, cargs)
Error checking on routines that should not return -1.
Error checking on routines that should not return -1.
def check_minus_one(result, func, cargs): "Error checking on routines that should not return -1." if result == -1: raise GEOSException('Error encountered in GEOS C function "%s".' % func.__name__) else: return result
[ "def", "check_minus_one", "(", "result", ",", "func", ",", "cargs", ")", ":", "if", "result", "==", "-", "1", ":", "raise", "GEOSException", "(", "'Error encountered in GEOS C function \"%s\".'", "%", "func", ".", "__name__", ")", "else", ":", "return", "resul...
[ 35, 0 ]
[ 40, 21 ]
python
en
['en', 'en', 'en']
True
check_predicate
(result, func, cargs)
Error checking for unary/binary predicate functions.
Error checking for unary/binary predicate functions.
def check_predicate(result, func, cargs): "Error checking for unary/binary predicate functions." if result == 1: return True elif result == 0: return False else: raise GEOSException('Error encountered on GEOS C predicate function "%s".' % func.__name__)
[ "def", "check_predicate", "(", "result", ",", "func", ",", "cargs", ")", ":", "if", "result", "==", "1", ":", "return", "True", "elif", "result", "==", "0", ":", "return", "False", "else", ":", "raise", "GEOSException", "(", "'Error encountered on GEOS C pre...
[ 43, 0 ]
[ 50, 99 ]
python
en
['en', 'en', 'en']
True
check_sized_string
(result, func, cargs)
Error checking for routines that return explicitly sized strings. This frees the memory allocated by GEOS at the result pointer.
Error checking for routines that return explicitly sized strings.
def check_sized_string(result, func, cargs): """ Error checking for routines that return explicitly sized strings. This frees the memory allocated by GEOS at the result pointer. """ if not result: raise GEOSException('Invalid string pointer returned by GEOS C function "%s"' % func.__name__)...
[ "def", "check_sized_string", "(", "result", ",", "func", ",", "cargs", ")", ":", "if", "not", "result", ":", "raise", "GEOSException", "(", "'Invalid string pointer returned by GEOS C function \"%s\"'", "%", "func", ".", "__name__", ")", "# A c_size_t object is passed i...
[ 53, 0 ]
[ 67, 12 ]
python
en
['en', 'error', 'th']
False
check_string
(result, func, cargs)
Error checking for routines that return strings. This frees the memory allocated by GEOS at the result pointer.
Error checking for routines that return strings.
def check_string(result, func, cargs): """ Error checking for routines that return strings. This frees the memory allocated by GEOS at the result pointer. """ if not result: raise GEOSException('Error encountered checking string return value in GEOS C function "%s".' % func.__name__) # ...
[ "def", "check_string", "(", "result", ",", "func", ",", "cargs", ")", ":", "if", "not", "result", ":", "raise", "GEOSException", "(", "'Error encountered checking string return value in GEOS C function \"%s\".'", "%", "func", ".", "__name__", ")", "# Getting the string ...
[ 70, 0 ]
[ 82, 12 ]
python
en
['en', 'error', 'th']
False
Storage.__init__
(self, session, model_class, key_name, key_value, property_name)
Constructor for Storage. Args: session: An instance of :class:`sqlalchemy.orm.Session`. model_class: SQLAlchemy declarative mapping. key_name: string, key name for the entity that has the credentials key_value: key value for the entity that has the credentials ...
Constructor for Storage.
def __init__(self, session, model_class, key_name, key_value, property_name): """Constructor for Storage. Args: session: An instance of :class:`sqlalchemy.orm.Session`. model_class: SQLAlchemy declarative mapping. key_name: string, key name for the e...
[ "def", "__init__", "(", "self", ",", "session", ",", "model_class", ",", "key_name", ",", "key_value", ",", "property_name", ")", ":", "super", "(", "Storage", ",", "self", ")", ".", "__init__", "(", ")", "self", ".", "session", "=", "session", "self", ...
[ 113, 4 ]
[ 133, 42 ]
python
en
['da', 'en', 'en']
True
Storage.locked_get
(self)
Retrieve stored credential. Returns: A :class:`oauth2client.Credentials` instance or `None`.
Retrieve stored credential.
def locked_get(self): """Retrieve stored credential. Returns: A :class:`oauth2client.Credentials` instance or `None`. """ filters = {self.key_name: self.key_value} query = self.session.query(self.model_class).filter_by(**filters) entity = query.first() ...
[ "def", "locked_get", "(", "self", ")", ":", "filters", "=", "{", "self", ".", "key_name", ":", "self", ".", "key_value", "}", "query", "=", "self", ".", "session", ".", "query", "(", "self", ".", "model_class", ")", ".", "filter_by", "(", "*", "*", ...
[ 135, 4 ]
[ 151, 23 ]
python
en
['en', 'pt', 'en']
True
Storage.locked_put
(self, credentials)
Write a credentials to the SQLAlchemy datastore. Args: credentials: :class:`oauth2client.Credentials`
Write a credentials to the SQLAlchemy datastore.
def locked_put(self, credentials): """Write a credentials to the SQLAlchemy datastore. Args: credentials: :class:`oauth2client.Credentials` """ filters = {self.key_name: self.key_value} query = self.session.query(self.model_class).filter_by(**filters) entity ...
[ "def", "locked_put", "(", "self", ",", "credentials", ")", ":", "filters", "=", "{", "self", ".", "key_name", ":", "self", ".", "key_value", "}", "query", "=", "self", ".", "session", ".", "query", "(", "self", ".", "model_class", ")", ".", "filter_by"...
[ 153, 4 ]
[ 167, 32 ]
python
en
['en', 'en', 'en']
True
Storage.locked_delete
(self)
Delete credentials from the SQLAlchemy datastore.
Delete credentials from the SQLAlchemy datastore.
def locked_delete(self): """Delete credentials from the SQLAlchemy datastore.""" filters = {self.key_name: self.key_value} self.session.query(self.model_class).filter_by(**filters).delete()
[ "def", "locked_delete", "(", "self", ")", ":", "filters", "=", "{", "self", ".", "key_name", ":", "self", ".", "key_value", "}", "self", ".", "session", ".", "query", "(", "self", ".", "model_class", ")", ".", "filter_by", "(", "*", "*", "filters", "...
[ 169, 4 ]
[ 172, 74 ]
python
en
['en', 'en', 'en']
True
_find_all_simple
(path)
Find all files under 'path'
Find all files under 'path'
def _find_all_simple(path): """ Find all files under 'path' """ results = ( os.path.join(base, file) for base, dirs, files in os.walk(path, followlinks=True) for file in files ) return filter(os.path.isfile, results)
[ "def", "_find_all_simple", "(", "path", ")", ":", "results", "=", "(", "os", ".", "path", ".", "join", "(", "base", ",", "file", ")", "for", "base", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "path", ",", "followlinks", "=", "True", ...
[ 155, 0 ]
[ 164, 42 ]
python
en
['en', 'error', 'th']
False
findall
(dir=os.curdir)
Find all files under 'dir' and return the list of full filenames. Unless dir is '.', return full filenames with dir prepended.
Find all files under 'dir' and return the list of full filenames. Unless dir is '.', return full filenames with dir prepended.
def findall(dir=os.curdir): """ Find all files under 'dir' and return the list of full filenames. Unless dir is '.', return full filenames with dir prepended. """ files = _find_all_simple(dir) if dir == os.curdir: make_rel = functools.partial(os.path.relpath, start=dir) files = m...
[ "def", "findall", "(", "dir", "=", "os", ".", "curdir", ")", ":", "files", "=", "_find_all_simple", "(", "dir", ")", "if", "dir", "==", "os", ".", "curdir", ":", "make_rel", "=", "functools", ".", "partial", "(", "os", ".", "path", ".", "relpath", ...
[ 167, 0 ]
[ 176, 22 ]
python
en
['en', 'error', 'th']
False
PackageFinder.find
(cls, where='.', exclude=(), include=('*',))
Return a list all Python packages found within directory 'where' 'where' is the root directory which will be searched for packages. It should be supplied as a "cross-platform" (i.e. URL-style) path; it will be converted to the appropriate local path syntax. 'exclude' is a sequence of ...
Return a list all Python packages found within directory 'where'
def find(cls, where='.', exclude=(), include=('*',)): """Return a list all Python packages found within directory 'where' 'where' is the root directory which will be searched for packages. It should be supplied as a "cross-platform" (i.e. URL-style) path; it will be converted to the ap...
[ "def", "find", "(", "cls", ",", "where", "=", "'.'", ",", "exclude", "=", "(", ")", ",", "include", "=", "(", "'*'", ",", ")", ")", ":", "return", "list", "(", "cls", ".", "_find_packages_iter", "(", "convert_path", "(", "where", ")", ",", "cls", ...
[ 39, 4 ]
[ 59, 41 ]
python
en
['en', 'en', 'en']
True
PackageFinder._find_packages_iter
(cls, where, exclude, include)
All the packages found in 'where' that pass the 'include' filter, but not the 'exclude' filter.
All the packages found in 'where' that pass the 'include' filter, but not the 'exclude' filter.
def _find_packages_iter(cls, where, exclude, include): """ All the packages found in 'where' that pass the 'include' filter, but not the 'exclude' filter. """ for root, dirs, files in os.walk(where, followlinks=True): # Copy dirs to iterate over it, then empty dirs. ...
[ "def", "_find_packages_iter", "(", "cls", ",", "where", ",", "exclude", ",", "include", ")", ":", "for", "root", ",", "dirs", ",", "files", "in", "os", ".", "walk", "(", "where", ",", "followlinks", "=", "True", ")", ":", "# Copy dirs to iterate over it, t...
[ 62, 4 ]
[ 87, 32 ]
python
en
['en', 'error', 'th']
False
PackageFinder._looks_like_package
(path)
Does a directory look like a package?
Does a directory look like a package?
def _looks_like_package(path): """Does a directory look like a package?""" return os.path.isfile(os.path.join(path, '__init__.py'))
[ "def", "_looks_like_package", "(", "path", ")", ":", "return", "os", ".", "path", ".", "isfile", "(", "os", ".", "path", ".", "join", "(", "path", ",", "'__init__.py'", ")", ")" ]
[ 90, 4 ]
[ 92, 64 ]
python
en
['en', 'en', 'en']
True
PackageFinder._build_filter
(*patterns)
Given a list of patterns, return a callable that will be true only if the input matches at least one of the patterns.
Given a list of patterns, return a callable that will be true only if the input matches at least one of the patterns.
def _build_filter(*patterns): """ Given a list of patterns, return a callable that will be true only if the input matches at least one of the patterns. """ return lambda name: any(fnmatchcase(name, pat=pat) for pat in patterns)
[ "def", "_build_filter", "(", "*", "patterns", ")", ":", "return", "lambda", "name", ":", "any", "(", "fnmatchcase", "(", "name", ",", "pat", "=", "pat", ")", "for", "pat", "in", "patterns", ")" ]
[ 95, 4 ]
[ 100, 79 ]
python
en
['en', 'error', 'th']
False
Command.__init__
(self, dist, **kw)
Construct the command for dist, updating vars(self) with any keyword parameters.
Construct the command for dist, updating vars(self) with any keyword parameters.
def __init__(self, dist, **kw): """ Construct the command for dist, updating vars(self) with any keyword parameters. """ _Command.__init__(self, dist) vars(self).update(kw)
[ "def", "__init__", "(", "self", ",", "dist", ",", "*", "*", "kw", ")", ":", "_Command", ".", "__init__", "(", "self", ",", "dist", ")", "vars", "(", "self", ")", ".", "update", "(", "kw", ")" ]
[ 141, 4 ]
[ 147, 29 ]
python
en
['en', 'error', 'th']
False
Paginator.validate_number
(self, number)
Validate the given 1-based page number.
Validate the given 1-based page number.
def validate_number(self, number): """Validate the given 1-based page number.""" try: if isinstance(number, float) and not number.is_integer(): raise ValueError number = int(number) except (TypeError, ValueError): raise PageNotAnInteger(_('That...
[ "def", "validate_number", "(", "self", ",", "number", ")", ":", "try", ":", "if", "isinstance", "(", "number", ",", "float", ")", "and", "not", "number", ".", "is_integer", "(", ")", ":", "raise", "ValueError", "number", "=", "int", "(", "number", ")",...
[ 43, 4 ]
[ 58, 21 ]
python
en
['en', 'en', 'en']
True
Paginator.get_page
(self, number)
Return a valid page, even if the page argument isn't a number or isn't in range.
Return a valid page, even if the page argument isn't a number or isn't in range.
def get_page(self, number): """ Return a valid page, even if the page argument isn't a number or isn't in range. """ try: number = self.validate_number(number) except PageNotAnInteger: number = 1 except EmptyPage: number = self....
[ "def", "get_page", "(", "self", ",", "number", ")", ":", "try", ":", "number", "=", "self", ".", "validate_number", "(", "number", ")", "except", "PageNotAnInteger", ":", "number", "=", "1", "except", "EmptyPage", ":", "number", "=", "self", ".", "num_pa...
[ 60, 4 ]
[ 71, 32 ]
python
en
['en', 'error', 'th']
False
Paginator.page
(self, number)
Return a Page object for the given 1-based page number.
Return a Page object for the given 1-based page number.
def page(self, number): """Return a Page object for the given 1-based page number.""" number = self.validate_number(number) bottom = (number - 1) * self.per_page top = bottom + self.per_page if top + self.orphans >= self.count: top = self.count return self._ge...
[ "def", "page", "(", "self", ",", "number", ")", ":", "number", "=", "self", ".", "validate_number", "(", "number", ")", "bottom", "=", "(", "number", "-", "1", ")", "*", "self", ".", "per_page", "top", "=", "bottom", "+", "self", ".", "per_page", "...
[ 73, 4 ]
[ 80, 73 ]
python
en
['en', 'en', 'en']
True
Paginator._get_page
(self, *args, **kwargs)
Return an instance of a single page. This hook can be used by subclasses to use an alternative to the standard :cls:`Page` object.
Return an instance of a single page.
def _get_page(self, *args, **kwargs): """ Return an instance of a single page. This hook can be used by subclasses to use an alternative to the standard :cls:`Page` object. """ return Page(*args, **kwargs)
[ "def", "_get_page", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "Page", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 82, 4 ]
[ 89, 36 ]
python
en
['en', 'error', 'th']
False
Paginator.count
(self)
Return the total number of objects, across all pages.
Return the total number of objects, across all pages.
def count(self): """Return the total number of objects, across all pages.""" c = getattr(self.object_list, 'count', None) if callable(c) and not inspect.isbuiltin(c) and method_has_no_args(c): return c() return len(self.object_list)
[ "def", "count", "(", "self", ")", ":", "c", "=", "getattr", "(", "self", ".", "object_list", ",", "'count'", ",", "None", ")", "if", "callable", "(", "c", ")", "and", "not", "inspect", ".", "isbuiltin", "(", "c", ")", "and", "method_has_no_args", "("...
[ 92, 4 ]
[ 97, 36 ]
python
en
['en', 'en', 'en']
True
Paginator.num_pages
(self)
Return the total number of pages.
Return the total number of pages.
def num_pages(self): """Return the total number of pages.""" if self.count == 0 and not self.allow_empty_first_page: return 0 hits = max(1, self.count - self.orphans) return ceil(hits / self.per_page)
[ "def", "num_pages", "(", "self", ")", ":", "if", "self", ".", "count", "==", "0", "and", "not", "self", ".", "allow_empty_first_page", ":", "return", "0", "hits", "=", "max", "(", "1", ",", "self", ".", "count", "-", "self", ".", "orphans", ")", "r...
[ 100, 4 ]
[ 105, 41 ]
python
en
['en', 'en', 'en']
True
Paginator.page_range
(self)
Return a 1-based range of pages for iterating through within a template for loop.
Return a 1-based range of pages for iterating through within a template for loop.
def page_range(self): """ Return a 1-based range of pages for iterating through within a template for loop. """ return range(1, self.num_pages + 1)
[ "def", "page_range", "(", "self", ")", ":", "return", "range", "(", "1", ",", "self", ".", "num_pages", "+", "1", ")" ]
[ 108, 4 ]
[ 113, 43 ]
python
en
['en', 'error', 'th']
False
Paginator._check_object_list_is_ordered
(self)
Warn if self.object_list is unordered (typically a QuerySet).
Warn if self.object_list is unordered (typically a QuerySet).
def _check_object_list_is_ordered(self): """ Warn if self.object_list is unordered (typically a QuerySet). """ ordered = getattr(self.object_list, 'ordered', None) if ordered is not None and not ordered: obj_list_repr = ( '{} {}'.format(self.object_lis...
[ "def", "_check_object_list_is_ordered", "(", "self", ")", ":", "ordered", "=", "getattr", "(", "self", ".", "object_list", ",", "'ordered'", ",", "None", ")", "if", "ordered", "is", "not", "None", "and", "not", "ordered", ":", "obj_list_repr", "=", "(", "'...
[ 115, 4 ]
[ 131, 13 ]
python
en
['en', 'error', 'th']
False
Paginator.get_elided_page_range
(self, number=1, *, on_each_side=3, on_ends=2)
Return a 1-based range of pages with some values elided. If the page range is larger than a given size, the whole range is not provided and a compact form is returned instead, e.g. for a paginator with 50 pages, if page 43 were the current page, the output, with the default arg...
Return a 1-based range of pages with some values elided.
def get_elided_page_range(self, number=1, *, on_each_side=3, on_ends=2): """ Return a 1-based range of pages with some values elided. If the page range is larger than a given size, the whole range is not provided and a compact form is returned instead, e.g. for a paginator with ...
[ "def", "get_elided_page_range", "(", "self", ",", "number", "=", "1", ",", "*", ",", "on_each_side", "=", "3", ",", "on_ends", "=", "2", ")", ":", "number", "=", "self", ".", "validate_number", "(", "number", ")", "if", "self", ".", "num_pages", "<=", ...
[ 133, 4 ]
[ 162, 60 ]
python
en
['en', 'error', 'th']
False