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
get_cached_http
()
Return an HTTP object which caches results returned. This is intended to be used in methods like oauth2client.client.verify_id_token(), which calls to the same URI to retrieve certs. Returns: httplib2.Http, an HTTP object with a MemoryCache
Return an HTTP object which caches results returned.
def get_cached_http(): """Return an HTTP object which caches results returned. This is intended to be used in methods like oauth2client.client.verify_id_token(), which calls to the same URI to retrieve certs. Returns: httplib2.Http, an HTTP object with a MemoryCache """ return _CAC...
[ "def", "get_cached_http", "(", ")", ":", "return", "_CACHED_HTTP" ]
[ 47, 0 ]
[ 57, 23 ]
python
en
['en', 'en', 'en']
True
get_http_object
(*args, **kwargs)
Return a new HTTP object. Args: *args: tuple, The positional arguments to be passed when contructing a new HTTP object. **kwargs: dict, The keyword arguments to be passed when contructing a new HTTP object. Returns: httplib2.Http, an HTTP object.
Return a new HTTP object.
def get_http_object(*args, **kwargs): """Return a new HTTP object. Args: *args: tuple, The positional arguments to be passed when contructing a new HTTP object. **kwargs: dict, The keyword arguments to be passed when contructing a new HTTP object. Returns: ...
[ "def", "get_http_object", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "httplib2", ".", "Http", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 60, 0 ]
[ 72, 41 ]
python
en
['en', 'en', 'en']
True
_initialize_headers
(headers)
Creates a copy of the headers. Args: headers: dict, request headers to copy. Returns: dict, the copied headers or a new dictionary if the headers were None.
Creates a copy of the headers.
def _initialize_headers(headers): """Creates a copy of the headers. Args: headers: dict, request headers to copy. Returns: dict, the copied headers or a new dictionary if the headers were None. """ return {} if headers is None else dict(headers)
[ "def", "_initialize_headers", "(", "headers", ")", ":", "return", "{", "}", "if", "headers", "is", "None", "else", "dict", "(", "headers", ")" ]
[ 75, 0 ]
[ 85, 51 ]
python
en
['en', 'en', 'en']
True
_apply_user_agent
(headers, user_agent)
Adds a user-agent to the headers. Args: headers: dict, request headers to add / modify user agent within. user_agent: str, the user agent to add. Returns: dict, the original headers passed in, but modified if the user agent is not None.
Adds a user-agent to the headers.
def _apply_user_agent(headers, user_agent): """Adds a user-agent to the headers. Args: headers: dict, request headers to add / modify user agent within. user_agent: str, the user agent to add. Returns: dict, the original headers passed in, but modified if the ...
[ "def", "_apply_user_agent", "(", "headers", ",", "user_agent", ")", ":", "if", "user_agent", "is", "not", "None", ":", "if", "'user-agent'", "in", "headers", ":", "headers", "[", "'user-agent'", "]", "=", "(", "user_agent", "+", "' '", "+", "headers", "[",...
[ 88, 0 ]
[ 106, 18 ]
python
en
['en', 'en', 'en']
True
clean_headers
(headers)
Forces header keys and values to be strings, i.e not unicode. The httplib module just concats the header keys and values in a way that may make the message header a unicode string, which, if it then tries to contatenate to a binary request body may result in a unicode decode error. Args: heade...
Forces header keys and values to be strings, i.e not unicode.
def clean_headers(headers): """Forces header keys and values to be strings, i.e not unicode. The httplib module just concats the header keys and values in a way that may make the message header a unicode string, which, if it then tries to contatenate to a binary request body may result in a unicode dec...
[ "def", "clean_headers", "(", "headers", ")", ":", "clean", "=", "{", "}", "try", ":", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "headers", ")", ":", "if", "not", "isinstance", "(", "k", ",", "six", ".", "binary_type", ")", ":", "k...
[ 109, 0 ]
[ 133, 16 ]
python
en
['en', 'en', 'en']
True
wrap_http_for_auth
(credentials, http)
Prepares an HTTP object's request method for auth. Wraps HTTP requests with logic to catch auth failures (typically identified via a 401 status code). In the event of failure, tries to refresh the token used and then retry the original request. Args: credentials: Credentials, the credentials u...
Prepares an HTTP object's request method for auth.
def wrap_http_for_auth(credentials, http): """Prepares an HTTP object's request method for auth. Wraps HTTP requests with logic to catch auth failures (typically identified via a 401 status code). In the event of failure, tries to refresh the token used and then retry the original request. Args: ...
[ "def", "wrap_http_for_auth", "(", "credentials", ",", "http", ")", ":", "orig_request_method", "=", "http", ".", "request", "# The closure that will replace 'httplib2.Http.request'.", "def", "new_request", "(", "uri", ",", "method", "=", "'GET'", ",", "body", "=", "...
[ 136, 0 ]
[ 200, 42 ]
python
en
['en', 'en', 'en']
True
wrap_http_for_jwt_access
(credentials, http)
Prepares an HTTP object's request method for JWT access. Wraps HTTP requests with logic to catch auth failures (typically identified via a 401 status code). In the event of failure, tries to refresh the token used and then retry the original request. Args: credentials: _JWTAccessCredentials, t...
Prepares an HTTP object's request method for JWT access.
def wrap_http_for_jwt_access(credentials, http): """Prepares an HTTP object's request method for JWT access. Wraps HTTP requests with logic to catch auth failures (typically identified via a 401 status code). In the event of failure, tries to refresh the token used and then retry the original request. ...
[ "def", "wrap_http_for_jwt_access", "(", "credentials", ",", "http", ")", ":", "orig_request_method", "=", "http", ".", "request", "wrap_http_for_auth", "(", "credentials", ",", "http", ")", "# The new value of ``http.request`` set by ``wrap_http_for_auth``.", "authenticated_r...
[ 203, 0 ]
[ 250, 42 ]
python
en
['en', 'en', 'en']
True
request
(http, uri, method='GET', body=None, headers=None, redirections=httplib2.DEFAULT_MAX_REDIRECTS, connection_type=None)
Make an HTTP request with an HTTP object and arguments. Args: http: httplib2.Http, an http object to be used to make requests. uri: string, The URI to be requested. method: string, The HTTP method to use for the request. Defaults to 'GET'. body: string, The payload /...
Make an HTTP request with an HTTP object and arguments.
def request(http, uri, method='GET', body=None, headers=None, redirections=httplib2.DEFAULT_MAX_REDIRECTS, connection_type=None): """Make an HTTP request with an HTTP object and arguments. Args: http: httplib2.Http, an http object to be used to make requests. uri: string...
[ "def", "request", "(", "http", ",", "uri", ",", "method", "=", "'GET'", ",", "body", "=", "None", ",", "headers", "=", "None", ",", "redirections", "=", "httplib2", ".", "DEFAULT_MAX_REDIRECTS", ",", "connection_type", "=", "None", ")", ":", "# NOTE: Allow...
[ 253, 0 ]
[ 281, 57 ]
python
en
['en', 'en', 'en']
True
_items
(mappingorseq)
Wrapper for efficient iteration over mappings represented by dicts or sequences:: >>> for k, v in _items((i, i*i) for i in xrange(5)): ... assert k*k == v >>> for k, v in _items(dict((i, i*i) for i in xrange(5))): ... assert k*k == v
Wrapper for efficient iteration over mappings represented by dicts or sequences::
def _items(mappingorseq): """Wrapper for efficient iteration over mappings represented by dicts or sequences:: >>> for k, v in _items((i, i*i) for i in xrange(5)): ... assert k*k == v >>> for k, v in _items(dict((i, i*i) for i in xrange(5))): ... assert k*k == v """ ...
[ "def", "_items", "(", "mappingorseq", ")", ":", "if", "hasattr", "(", "mappingorseq", ",", "\"items\"", ")", ":", "return", "iteritems", "(", "mappingorseq", ")", "return", "mappingorseq" ]
[ 88, 0 ]
[ 101, 23 ]
python
en
['en', 'en', 'en']
True
BaseCache.get
(self, key)
Look up key in the cache and return the value for it. :param key: the key to be looked up. :returns: The value if it exists and is readable, else ``None``.
Look up key in the cache and return the value for it.
def get(self, key): """Look up key in the cache and return the value for it. :param key: the key to be looked up. :returns: The value if it exists and is readable, else ``None``. """ return None
[ "def", "get", "(", "self", ",", "key", ")", ":", "return", "None" ]
[ 121, 4 ]
[ 127, 19 ]
python
en
['en', 'en', 'en']
True
BaseCache.delete
(self, key)
Delete `key` from the cache. :param key: the key to delete. :returns: Whether the key existed and has been deleted. :rtype: boolean
Delete `key` from the cache.
def delete(self, key): """Delete `key` from the cache. :param key: the key to delete. :returns: Whether the key existed and has been deleted. :rtype: boolean """ return True
[ "def", "delete", "(", "self", ",", "key", ")", ":", "return", "True" ]
[ 129, 4 ]
[ 136, 19 ]
python
en
['en', 'en', 'en']
True
BaseCache.get_many
(self, *keys)
Returns a list of values for the given keys. For each key an item in the list is created:: foo, bar = cache.get_many("foo", "bar") Has the same error handling as :meth:`get`. :param keys: The function accepts multiple keys as positional arguments.
Returns a list of values for the given keys. For each key an item in the list is created::
def get_many(self, *keys): """Returns a list of values for the given keys. For each key an item in the list is created:: foo, bar = cache.get_many("foo", "bar") Has the same error handling as :meth:`get`. :param keys: The function accepts multiple keys as positional ...
[ "def", "get_many", "(", "self", ",", "*", "keys", ")", ":", "return", "[", "self", ".", "get", "(", "k", ")", "for", "k", "in", "keys", "]" ]
[ 138, 4 ]
[ 149, 42 ]
python
en
['en', 'en', 'en']
True
BaseCache.get_dict
(self, *keys)
Like :meth:`get_many` but return a dict:: d = cache.get_dict("foo", "bar") foo = d["foo"] bar = d["bar"] :param keys: The function accepts multiple keys as positional arguments.
Like :meth:`get_many` but return a dict::
def get_dict(self, *keys): """Like :meth:`get_many` but return a dict:: d = cache.get_dict("foo", "bar") foo = d["foo"] bar = d["bar"] :param keys: The function accepts multiple keys as positional arguments. """ return dict(zip(k...
[ "def", "get_dict", "(", "self", ",", "*", "keys", ")", ":", "return", "dict", "(", "zip", "(", "keys", ",", "self", ".", "get_many", "(", "*", "keys", ")", ")", ")" ]
[ 151, 4 ]
[ 161, 52 ]
python
en
['en', 'en', 'en']
True
BaseCache.set
(self, key, value, timeout=None)
Add a new key/value to the cache (overwrites value, if key already exists in the cache). :param key: the key to set :param value: the value for the key :param timeout: the cache timeout for the key in seconds (if not specified, it uses the default timeout). A tim...
Add a new key/value to the cache (overwrites value, if key already exists in the cache).
def set(self, key, value, timeout=None): """Add a new key/value to the cache (overwrites value, if key already exists in the cache). :param key: the key to set :param value: the value for the key :param timeout: the cache timeout for the key in seconds (if not ...
[ "def", "set", "(", "self", ",", "key", ",", "value", ",", "timeout", "=", "None", ")", ":", "return", "True" ]
[ 163, 4 ]
[ 177, 19 ]
python
en
['en', 'en', 'en']
True
BaseCache.add
(self, key, value, timeout=None)
Works like :meth:`set` but does not overwrite the values of already existing keys. :param key: the key to set :param value: the value for the key :param timeout: the cache timeout for the key in seconds (if not specified, it uses the default timeout). A timeout o...
Works like :meth:`set` but does not overwrite the values of already existing keys.
def add(self, key, value, timeout=None): """Works like :meth:`set` but does not overwrite the values of already existing keys. :param key: the key to set :param value: the value for the key :param timeout: the cache timeout for the key in seconds (if not ...
[ "def", "add", "(", "self", ",", "key", ",", "value", ",", "timeout", "=", "None", ")", ":", "return", "True" ]
[ 179, 4 ]
[ 192, 19 ]
python
en
['en', 'en', 'en']
True
BaseCache.set_many
(self, mapping, timeout=None)
Sets multiple keys and values from a mapping. :param mapping: a mapping with the keys/values to set. :param timeout: the cache timeout for the key in seconds (if not specified, it uses the default timeout). A timeout of 0 idicates that the cache never exp...
Sets multiple keys and values from a mapping.
def set_many(self, mapping, timeout=None): """Sets multiple keys and values from a mapping. :param mapping: a mapping with the keys/values to set. :param timeout: the cache timeout for the key in seconds (if not specified, it uses the default timeout). A timeout of ...
[ "def", "set_many", "(", "self", ",", "mapping", ",", "timeout", "=", "None", ")", ":", "rv", "=", "True", "for", "key", ",", "value", "in", "_items", "(", "mapping", ")", ":", "if", "not", "self", ".", "set", "(", "key", ",", "value", ",", "timeo...
[ 194, 4 ]
[ 208, 17 ]
python
en
['en', 'en', 'en']
True
BaseCache.delete_many
(self, *keys)
Deletes multiple keys at once. :param keys: The function accepts multiple keys as positional arguments. :returns: Whether all given keys have been deleted. :rtype: boolean
Deletes multiple keys at once.
def delete_many(self, *keys): """Deletes multiple keys at once. :param keys: The function accepts multiple keys as positional arguments. :returns: Whether all given keys have been deleted. :rtype: boolean """ return all(self.delete(key) for key in ke...
[ "def", "delete_many", "(", "self", ",", "*", "keys", ")", ":", "return", "all", "(", "self", ".", "delete", "(", "key", ")", "for", "key", "in", "keys", ")" ]
[ 210, 4 ]
[ 218, 52 ]
python
en
['en', 'da', 'en']
True
BaseCache.has
(self, key)
Checks if a key exists in the cache without returning it. This is a cheap operation that bypasses loading the actual data on the backend. This method is optional and may not be implemented on all caches. :param key: the key to check
Checks if a key exists in the cache without returning it. This is a cheap operation that bypasses loading the actual data on the backend.
def has(self, key): """Checks if a key exists in the cache without returning it. This is a cheap operation that bypasses loading the actual data on the backend. This method is optional and may not be implemented on all caches. :param key: the key to check """ raise NotI...
[ "def", "has", "(", "self", ",", "key", ")", ":", "raise", "NotImplementedError", "(", "\"%s doesn't have an efficient implementation of `has`. That \"", "\"means it is impossible to check whether a key exists without \"", "\"fully loading the key's data. Consider using `self.get` \"", "\...
[ 220, 4 ]
[ 233, 9 ]
python
en
['en', 'en', 'en']
True
BaseCache.clear
(self)
Clears the cache. Keep in mind that not all caches support completely clearing the cache. :returns: Whether the cache has been cleared. :rtype: boolean
Clears the cache. Keep in mind that not all caches support completely clearing the cache.
def clear(self): """Clears the cache. Keep in mind that not all caches support completely clearing the cache. :returns: Whether the cache has been cleared. :rtype: boolean """ return True
[ "def", "clear", "(", "self", ")", ":", "return", "True" ]
[ 235, 4 ]
[ 242, 19 ]
python
en
['en', 'en', 'en']
True
BaseCache.inc
(self, key, delta=1)
Increments the value of a key by `delta`. If the key does not yet exist it is initialized with `delta`. For supporting caches this is an atomic operation. :param key: the key to increment. :param delta: the delta to add. :returns: The new value or ``None`` for backend errors. ...
Increments the value of a key by `delta`. If the key does not yet exist it is initialized with `delta`.
def inc(self, key, delta=1): """Increments the value of a key by `delta`. If the key does not yet exist it is initialized with `delta`. For supporting caches this is an atomic operation. :param key: the key to increment. :param delta: the delta to add. :returns: The ne...
[ "def", "inc", "(", "self", ",", "key", ",", "delta", "=", "1", ")", ":", "value", "=", "(", "self", ".", "get", "(", "key", ")", "or", "0", ")", "+", "delta", "return", "value", "if", "self", ".", "set", "(", "key", ",", "value", ")", "else",...
[ 244, 4 ]
[ 255, 54 ]
python
en
['en', 'en', 'en']
True
BaseCache.dec
(self, key, delta=1)
Decrements the value of a key by `delta`. If the key does not yet exist it is initialized with `-delta`. For supporting caches this is an atomic operation. :param key: the key to increment. :param delta: the delta to subtract. :returns: The new value or `None` for backend erro...
Decrements the value of a key by `delta`. If the key does not yet exist it is initialized with `-delta`.
def dec(self, key, delta=1): """Decrements the value of a key by `delta`. If the key does not yet exist it is initialized with `-delta`. For supporting caches this is an atomic operation. :param key: the key to increment. :param delta: the delta to subtract. :returns: ...
[ "def", "dec", "(", "self", ",", "key", ",", "delta", "=", "1", ")", ":", "value", "=", "(", "self", ".", "get", "(", "key", ")", "or", "0", ")", "-", "delta", "return", "value", "if", "self", ".", "set", "(", "key", ",", "value", ")", "else",...
[ 257, 4 ]
[ 268, 54 ]
python
en
['en', 'en', 'en']
True
MemcachedCache.import_preferred_memcache_lib
(self, servers)
Returns an initialized memcache client. Used by the constructor.
Returns an initialized memcache client. Used by the constructor.
def import_preferred_memcache_lib(self, servers): """Returns an initialized memcache client. Used by the constructor.""" try: import pylibmc except ImportError: pass else: return pylibmc.Client(servers) try: from google.appengine....
[ "def", "import_preferred_memcache_lib", "(", "self", ",", "servers", ")", ":", "try", ":", "import", "pylibmc", "except", "ImportError", ":", "pass", "else", ":", "return", "pylibmc", ".", "Client", "(", "servers", ")", "try", ":", "from", "google", ".", "...
[ 499, 4 ]
[ 527, 40 ]
python
en
['en', 'en', 'en']
True
RedisCache.dump_object
(self, value)
Dumps an object into a string for redis. By default it serializes integers as regular string and pickle dumps everything else.
Dumps an object into a string for redis. By default it serializes integers as regular string and pickle dumps everything else.
def dump_object(self, value): """Dumps an object into a string for redis. By default it serializes integers as regular string and pickle dumps everything else. """ t = type(value) if t in integer_types: return str(value).encode("ascii") return b"!" + pickle.d...
[ "def", "dump_object", "(", "self", ",", "value", ")", ":", "t", "=", "type", "(", "value", ")", "if", "t", "in", "integer_types", ":", "return", "str", "(", "value", ")", ".", "encode", "(", "\"ascii\"", ")", "return", "b\"!\"", "+", "pickle", ".", ...
[ 603, 4 ]
[ 610, 41 ]
python
en
['en', 'en', 'en']
True
RedisCache.load_object
(self, value)
The reversal of :meth:`dump_object`. This might be called with None.
The reversal of :meth:`dump_object`. This might be called with None.
def load_object(self, value): """The reversal of :meth:`dump_object`. This might be called with None. """ if value is None: return None if value.startswith(b"!"): try: return pickle.loads(value[1:]) except pickle.PickleError: ...
[ "def", "load_object", "(", "self", ",", "value", ")", ":", "if", "value", "is", "None", ":", "return", "None", "if", "value", ".", "startswith", "(", "b\"!\"", ")", ":", "try", ":", "return", "pickle", ".", "loads", "(", "value", "[", "1", ":", "]"...
[ 612, 4 ]
[ 627, 24 ]
python
en
['en', 'en', 'en']
True
FileSystemCache._list_dir
(self)
return a list of (fully qualified) cache filenames
return a list of (fully qualified) cache filenames
def _list_dir(self): """return a list of (fully qualified) cache filenames """ mgmt_files = [ self._get_filename(name).split("/")[-1] for name in (self._fs_count_file,) ] return [ os.path.join(self._path, fn) for fn in os.listdir(self._path) ...
[ "def", "_list_dir", "(", "self", ")", ":", "mgmt_files", "=", "[", "self", ".", "_get_filename", "(", "name", ")", ".", "split", "(", "\"/\"", ")", "[", "-", "1", "]", "for", "name", "in", "(", "self", ".", "_fs_count_file", ",", ")", "]", "return"...
[ 755, 4 ]
[ 765, 9 ]
python
en
['en', 'en', 'en']
True
MatrixFactorization.__init__
(self, train_file=None, test_file=None, output_file=None, factors=10, learn_rate=0.01, epochs=30, delta=0.015, init_mean=0.1, init_stdev=0.1, baseline=False, bias_learn_rate=0.005, delta_bias=0.002, stop_criteria=0.009, sep='\t', output_sep='\t', random_seed=None)
Matrix Factorization for rating prediction Matrix factorization models map both users and items to a joint latent factor space of dimensionality f, such that user-item interactions are modeled as inner products in that space. Usage:: >> MatrixFactorization(train, test).co...
Matrix Factorization for rating prediction
def __init__(self, train_file=None, test_file=None, output_file=None, factors=10, learn_rate=0.01, epochs=30, delta=0.015, init_mean=0.1, init_stdev=0.1, baseline=False, bias_learn_rate=0.005, delta_bias=0.002, stop_criteria=0.009, sep='\t', output_sep='\t', random_seed=None): ...
[ "def", "__init__", "(", "self", ",", "train_file", "=", "None", ",", "test_file", "=", "None", ",", "output_file", "=", "None", ",", "factors", "=", "10", ",", "learn_rate", "=", "0.01", ",", "epochs", "=", "30", ",", "delta", "=", "0.015", ",", "ini...
[ 24, 4 ]
[ 112, 22 ]
python
en
['en', 'error', 'th']
False
MatrixFactorization.init_model
(self)
Method to treat and initialize the model
Method to treat and initialize the model
def init_model(self): """ Method to treat and initialize the model """ self.feedback_triples = [] # Map interaction with ids for user in self.train_set['feedback']: for item in self.train_set['feedback'][user]: self.feedback_triples.append((s...
[ "def", "init_model", "(", "self", ")", ":", "self", ".", "feedback_triples", "=", "[", "]", "# Map interaction with ids", "for", "user", "in", "self", ".", "train_set", "[", "'feedback'", "]", ":", "for", "item", "in", "self", ".", "train_set", "[", "'feed...
[ 114, 4 ]
[ 128, 29 ]
python
en
['en', 'error', 'th']
False
MatrixFactorization.fit
(self)
This method performs iterations of stochastic gradient ascent over the training data.
This method performs iterations of stochastic gradient ascent over the training data.
def fit(self): """ This method performs iterations of stochastic gradient ascent over the training data. """ rmse_old = .0 for epoch in range(self.epochs): error_final = .0 for user, item, feedback in self.feedback_triples: eui = feed...
[ "def", "fit", "(", "self", ")", ":", "rmse_old", "=", ".0", "for", "epoch", "in", "range", "(", "self", ".", "epochs", ")", ":", "error_final", "=", ".0", "for", "user", ",", "item", ",", "feedback", "in", "self", ".", "feedback_triples", ":", "eui",...
[ 130, 4 ]
[ 167, 35 ]
python
en
['en', 'error', 'th']
False
MatrixFactorization.create_factors
(self)
This method create factors for users, items and bias
This method create factors for users, items and bias
def create_factors(self): """ This method create factors for users, items and bias """ self.p = np.random.normal(self.init_mean, self.init_stdev, (len(self.users), self.factors)) self.q = np.random.normal(self.init_mean, self.init_stdev, (len(self.items), self.factors)) ...
[ "def", "create_factors", "(", "self", ")", ":", "self", ".", "p", "=", "np", ".", "random", ".", "normal", "(", "self", ".", "init_mean", ",", "self", ".", "init_stdev", ",", "(", "len", "(", "self", ".", "users", ")", ",", "self", ".", "factors", ...
[ 169, 4 ]
[ 180, 58 ]
python
en
['en', 'error', 'th']
False
MatrixFactorization._predict_score
(self, u, i, cond=True)
Method to predict a single score for a pair (user, item) :param u: User ID :type u: int :param i: Item ID :type i: int :param cond: Use max and min values of train set to limit score :type cond: bool, default True :return: Score generate for pair (use...
Method to predict a single score for a pair (user, item)
def _predict_score(self, u, i, cond=True): """ Method to predict a single score for a pair (user, item) :param u: User ID :type u: int :param i: Item ID :type i: int :param cond: Use max and min values of train set to limit score :type cond: bool, defau...
[ "def", "_predict_score", "(", "self", ",", "u", ",", "i", ",", "cond", "=", "True", ")", ":", "if", "self", ".", "baseline", ":", "rui", "=", "self", ".", "train_set", "[", "\"mean_value\"", "]", "+", "self", ".", "bu", "[", "u", "]", "+", "self"...
[ 182, 4 ]
[ 211, 18 ]
python
en
['en', 'error', 'th']
False
MatrixFactorization.predict
(self)
This method computes a final rating for unknown pairs (user, item)
This method computes a final rating for unknown pairs (user, item)
def predict(self): """ This method computes a final rating for unknown pairs (user, item) """ if self.test_file is not None: for user in self.test_set['users']: for item in self.test_set['feedback'][user]: self.predictions.append((user, i...
[ "def", "predict", "(", "self", ")", ":", "if", "self", ".", "test_file", "is", "not", "None", ":", "for", "user", "in", "self", ".", "test_set", "[", "'users'", "]", ":", "for", "item", "in", "self", ".", "test_set", "[", "'feedback'", "]", "[", "u...
[ 213, 4 ]
[ 225, 32 ]
python
en
['en', 'error', 'th']
False
MatrixFactorization.compute
(self, verbose=True, metrics=None, verbose_evaluation=True, as_table=False, table_sep='\t')
Extends compute method from BaseRatingPrediction. Method to run recommender algorithm :param verbose: Print recommender and database information :type verbose: bool, default True :param metrics: List of evaluation measures :type metrics: list, default None :param verb...
Extends compute method from BaseRatingPrediction. Method to run recommender algorithm
def compute(self, verbose=True, metrics=None, verbose_evaluation=True, as_table=False, table_sep='\t'): """ Extends compute method from BaseRatingPrediction. Method to run recommender algorithm :param verbose: Print recommender and database information :type verbose: bool, default True ...
[ "def", "compute", "(", "self", ",", "verbose", "=", "True", ",", "metrics", "=", "None", ",", "verbose_evaluation", "=", "True", ",", "as_table", "=", "False", ",", "table_sep", "=", "'\\t'", ")", ":", "super", "(", "MatrixFactorization", ",", "self", ")...
[ 227, 4 ]
[ 269, 94 ]
python
en
['en', 'error', 'th']
False
fast_exit
(code)
Exit without garbage collection, this speeds up exit by about 10ms for things like bash completion.
Exit without garbage collection, this speeds up exit by about 10ms for things like bash completion.
def fast_exit(code): """Exit without garbage collection, this speeds up exit by about 10ms for things like bash completion. """ sys.stdout.flush() sys.stderr.flush() os._exit(code)
[ "def", "fast_exit", "(", "code", ")", ":", "sys", ".", "stdout", ".", "flush", "(", ")", "sys", ".", "stderr", ".", "flush", "(", ")", "os", ".", "_exit", "(", "code", ")" ]
[ 38, 0 ]
[ 44, 18 ]
python
en
['en', 'en', 'en']
True
_bashcomplete
(cmd, prog_name, complete_var=None)
Internal handler for the bash completion support.
Internal handler for the bash completion support.
def _bashcomplete(cmd, prog_name, complete_var=None): """Internal handler for the bash completion support.""" if complete_var is None: complete_var = '_%s_COMPLETE' % (prog_name.replace('-', '_')).upper() complete_instr = os.environ.get(complete_var) if not complete_instr: return fr...
[ "def", "_bashcomplete", "(", "cmd", ",", "prog_name", ",", "complete_var", "=", "None", ")", ":", "if", "complete_var", "is", "None", ":", "complete_var", "=", "'_%s_COMPLETE'", "%", "(", "prog_name", ".", "replace", "(", "'-'", ",", "'_'", ")", ")", "."...
[ 47, 0 ]
[ 57, 20 ]
python
en
['en', 'da', 'en']
True
augment_usage_errors
(ctx, param=None)
Context manager that attaches extra information to exceptions that fly.
Context manager that attaches extra information to exceptions that fly.
def augment_usage_errors(ctx, param=None): """Context manager that attaches extra information to exceptions that fly. """ try: yield except BadParameter as e: if e.ctx is None: e.ctx = ctx if param is not None and e.param is None: e.param = param ...
[ "def", "augment_usage_errors", "(", "ctx", ",", "param", "=", "None", ")", ":", "try", ":", "yield", "except", "BadParameter", "as", "e", ":", "if", "e", ".", "ctx", "is", "None", ":", "e", ".", "ctx", "=", "ctx", "if", "param", "is", "not", "None"...
[ 99, 0 ]
[ 114, 13 ]
python
en
['en', 'en', 'en']
True
iter_params_for_processing
(invocation_order, declaration_order)
Given a sequence of parameters in the order as should be considered for processing and an iterable of parameters that exist, this returns a list in the correct order as they should be processed.
Given a sequence of parameters in the order as should be considered for processing and an iterable of parameters that exist, this returns a list in the correct order as they should be processed.
def iter_params_for_processing(invocation_order, declaration_order): """Given a sequence of parameters in the order as should be considered for processing and an iterable of parameters that exist, this returns a list in the correct order as they should be processed. """ def sort_key(item): t...
[ "def", "iter_params_for_processing", "(", "invocation_order", ",", "declaration_order", ")", ":", "def", "sort_key", "(", "item", ")", ":", "try", ":", "idx", "=", "invocation_order", ".", "index", "(", "item", ")", "except", "ValueError", ":", "idx", "=", "...
[ 117, 0 ]
[ 129, 50 ]
python
en
['en', 'en', 'en']
True
Context.scope
(self, cleanup=True)
This helper method can be used with the context object to promote it to the current thread local (see :func:`get_current_context`). The default behavior of this is to invoke the cleanup functions which can be disabled by setting `cleanup` to `False`. The cleanup functions are typically ...
This helper method can be used with the context object to promote it to the current thread local (see :func:`get_current_context`). The default behavior of this is to invoke the cleanup functions which can be disabled by setting `cleanup` to `False`. The cleanup functions are typically ...
def scope(self, cleanup=True): """This helper method can be used with the context object to promote it to the current thread local (see :func:`get_current_context`). The default behavior of this is to invoke the cleanup functions which can be disabled by setting `cleanup` to `False`. Th...
[ "def", "scope", "(", "self", ",", "cleanup", "=", "True", ")", ":", "if", "not", "cleanup", ":", "self", ".", "_depth", "+=", "1", "try", ":", "with", "self", "as", "rv", ":", "yield", "rv", "finally", ":", "if", "not", "cleanup", ":", "self", "....
[ 354, 4 ]
[ 389, 32 ]
python
en
['en', 'en', 'en']
True
Context.meta
(self)
This is a dictionary which is shared with all the contexts that are nested. It exists so that click utilities can store some state here if they need to. It is however the responsibility of that code to manage this dictionary well. The keys are supposed to be unique dotted strings. Fo...
This is a dictionary which is shared with all the contexts that are nested. It exists so that click utilities can store some state here if they need to. It is however the responsibility of that code to manage this dictionary well.
def meta(self): """This is a dictionary which is shared with all the contexts that are nested. It exists so that click utilities can store some state here if they need to. It is however the responsibility of that code to manage this dictionary well. The keys are supposed to be...
[ "def", "meta", "(", "self", ")", ":", "return", "self", ".", "_meta" ]
[ 392, 4 ]
[ 417, 25 ]
python
en
['en', 'en', 'en']
True
Context.make_formatter
(self)
Creates the formatter for the help and usage output.
Creates the formatter for the help and usage output.
def make_formatter(self): """Creates the formatter for the help and usage output.""" return HelpFormatter(width=self.terminal_width, max_width=self.max_content_width)
[ "def", "make_formatter", "(", "self", ")", ":", "return", "HelpFormatter", "(", "width", "=", "self", ".", "terminal_width", ",", "max_width", "=", "self", ".", "max_content_width", ")" ]
[ 419, 4 ]
[ 422, 62 ]
python
en
['en', 'en', 'en']
True
Context.call_on_close
(self, f)
This decorator remembers a function as callback that should be executed when the context tears down. This is most useful to bind resource handling to the script execution. For instance, file objects opened by the :class:`File` type will register their close callbacks here. :pa...
This decorator remembers a function as callback that should be executed when the context tears down. This is most useful to bind resource handling to the script execution. For instance, file objects opened by the :class:`File` type will register their close callbacks here.
def call_on_close(self, f): """This decorator remembers a function as callback that should be executed when the context tears down. This is most useful to bind resource handling to the script execution. For instance, file objects opened by the :class:`File` type will register their clo...
[ "def", "call_on_close", "(", "self", ",", "f", ")", ":", "self", ".", "_close_callbacks", ".", "append", "(", "f", ")", "return", "f" ]
[ 424, 4 ]
[ 434, 16 ]
python
en
['en', 'en', 'en']
True
Context.close
(self)
Invokes all close callbacks.
Invokes all close callbacks.
def close(self): """Invokes all close callbacks.""" for cb in self._close_callbacks: cb() self._close_callbacks = []
[ "def", "close", "(", "self", ")", ":", "for", "cb", "in", "self", ".", "_close_callbacks", ":", "cb", "(", ")", "self", ".", "_close_callbacks", "=", "[", "]" ]
[ 436, 4 ]
[ 440, 34 ]
python
en
['en', 'sm', 'en']
True
Context.command_path
(self)
The computed command path. This is used for the ``usage`` information on the help page. It's automatically created by combining the info names of the chain of contexts to the root.
The computed command path. This is used for the ``usage`` information on the help page. It's automatically created by combining the info names of the chain of contexts to the root.
def command_path(self): """The computed command path. This is used for the ``usage`` information on the help page. It's automatically created by combining the info names of the chain of contexts to the root. """ rv = '' if self.info_name is not None: rv = se...
[ "def", "command_path", "(", "self", ")", ":", "rv", "=", "''", "if", "self", ".", "info_name", "is", "not", "None", ":", "rv", "=", "self", ".", "info_name", "if", "self", ".", "parent", "is", "not", "None", ":", "rv", "=", "self", ".", "parent", ...
[ 443, 4 ]
[ 453, 26 ]
python
en
['en', 'en', 'en']
True
Context.find_root
(self)
Finds the outermost context.
Finds the outermost context.
def find_root(self): """Finds the outermost context.""" node = self while node.parent is not None: node = node.parent return node
[ "def", "find_root", "(", "self", ")", ":", "node", "=", "self", "while", "node", ".", "parent", "is", "not", "None", ":", "node", "=", "node", ".", "parent", "return", "node" ]
[ 455, 4 ]
[ 460, 19 ]
python
en
['en', 'en', 'en']
True
Context.find_object
(self, object_type)
Finds the closest object of a given type.
Finds the closest object of a given type.
def find_object(self, object_type): """Finds the closest object of a given type.""" node = self while node is not None: if isinstance(node.obj, object_type): return node.obj node = node.parent
[ "def", "find_object", "(", "self", ",", "object_type", ")", ":", "node", "=", "self", "while", "node", "is", "not", "None", ":", "if", "isinstance", "(", "node", ".", "obj", ",", "object_type", ")", ":", "return", "node", ".", "obj", "node", "=", "no...
[ 462, 4 ]
[ 468, 30 ]
python
en
['en', 'en', 'en']
True
Context.ensure_object
(self, object_type)
Like :meth:`find_object` but sets the innermost object to a new instance of `object_type` if it does not exist.
Like :meth:`find_object` but sets the innermost object to a new instance of `object_type` if it does not exist.
def ensure_object(self, object_type): """Like :meth:`find_object` but sets the innermost object to a new instance of `object_type` if it does not exist. """ rv = self.find_object(object_type) if rv is None: self.obj = rv = object_type() return rv
[ "def", "ensure_object", "(", "self", ",", "object_type", ")", ":", "rv", "=", "self", ".", "find_object", "(", "object_type", ")", "if", "rv", "is", "None", ":", "self", ".", "obj", "=", "rv", "=", "object_type", "(", ")", "return", "rv" ]
[ 470, 4 ]
[ 477, 17 ]
python
en
['en', 'en', 'en']
True
Context.lookup_default
(self, name)
Looks up the default for a parameter name. This by default looks into the :attr:`default_map` if available.
Looks up the default for a parameter name. This by default looks into the :attr:`default_map` if available.
def lookup_default(self, name): """Looks up the default for a parameter name. This by default looks into the :attr:`default_map` if available. """ if self.default_map is not None: rv = self.default_map.get(name) if callable(rv): rv = rv() ...
[ "def", "lookup_default", "(", "self", ",", "name", ")", ":", "if", "self", ".", "default_map", "is", "not", "None", ":", "rv", "=", "self", ".", "default_map", ".", "get", "(", "name", ")", "if", "callable", "(", "rv", ")", ":", "rv", "=", "rv", ...
[ 479, 4 ]
[ 487, 21 ]
python
en
['en', 'en', 'en']
True
Context.fail
(self, message)
Aborts the execution of the program with a specific error message. :param message: the error message to fail with.
Aborts the execution of the program with a specific error message.
def fail(self, message): """Aborts the execution of the program with a specific error message. :param message: the error message to fail with. """ raise UsageError(message, self)
[ "def", "fail", "(", "self", ",", "message", ")", ":", "raise", "UsageError", "(", "message", ",", "self", ")" ]
[ 489, 4 ]
[ 495, 39 ]
python
en
['en', 'en', 'en']
True
Context.abort
(self)
Aborts the script.
Aborts the script.
def abort(self): """Aborts the script.""" raise Abort()
[ "def", "abort", "(", "self", ")", ":", "raise", "Abort", "(", ")" ]
[ 497, 4 ]
[ 499, 21 ]
python
en
['en', 'it', 'en']
True
Context.exit
(self, code=0)
Exits the application with a given exit code.
Exits the application with a given exit code.
def exit(self, code=0): """Exits the application with a given exit code.""" raise Exit(code)
[ "def", "exit", "(", "self", ",", "code", "=", "0", ")", ":", "raise", "Exit", "(", "code", ")" ]
[ 501, 4 ]
[ 503, 24 ]
python
en
['en', 'en', 'en']
True
Context.get_usage
(self)
Helper method to get formatted usage string for the current context and command.
Helper method to get formatted usage string for the current context and command.
def get_usage(self): """Helper method to get formatted usage string for the current context and command. """ return self.command.get_usage(self)
[ "def", "get_usage", "(", "self", ")", ":", "return", "self", ".", "command", ".", "get_usage", "(", "self", ")" ]
[ 505, 4 ]
[ 509, 43 ]
python
en
['en', 'en', 'en']
True
Context.get_help
(self)
Helper method to get formatted help page for the current context and command.
Helper method to get formatted help page for the current context and command.
def get_help(self): """Helper method to get formatted help page for the current context and command. """ return self.command.get_help(self)
[ "def", "get_help", "(", "self", ")", ":", "return", "self", ".", "command", ".", "get_help", "(", "self", ")" ]
[ 511, 4 ]
[ 515, 42 ]
python
en
['en', 'en', 'en']
True
Context.invoke
(*args, **kwargs)
Invokes a command callback in exactly the way it expects. There are two ways to invoke this method: 1. the first argument can be a callback and all other arguments and keyword arguments are forwarded directly to the function. 2. the first argument is a click command object. In t...
Invokes a command callback in exactly the way it expects. There are two ways to invoke this method:
def invoke(*args, **kwargs): """Invokes a command callback in exactly the way it expects. There are two ways to invoke this method: 1. the first argument can be a callback and all other arguments and keyword arguments are forwarded directly to the function. 2. the first a...
[ "def", "invoke", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ",", "callback", "=", "args", "[", ":", "2", "]", "ctx", "=", "self", "# It's also possible to invoke another command which might or", "# might not have a callback. In that case we also fil...
[ 517, 4 ]
[ 554, 48 ]
python
en
['en', 'en', 'en']
True
Context.forward
(*args, **kwargs)
Similar to :meth:`invoke` but fills in default keyword arguments from the current context if the other command expects it. This cannot invoke callbacks directly, only other commands.
Similar to :meth:`invoke` but fills in default keyword arguments from the current context if the other command expects it. This cannot invoke callbacks directly, only other commands.
def forward(*args, **kwargs): """Similar to :meth:`invoke` but fills in default keyword arguments from the current context if the other command expects it. This cannot invoke callbacks directly, only other commands. """ self, cmd = args[:2] # It's also possible to invok...
[ "def", "forward", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ",", "cmd", "=", "args", "[", ":", "2", "]", "# It's also possible to invoke another command which might or", "# might not have a callback.", "if", "not", "isinstance", "(", "cmd", ",...
[ 556, 4 ]
[ 572, 41 ]
python
en
['en', 'id', 'en']
True
BaseCommand.make_context
(self, info_name, args, parent=None, **extra)
This function when given an info name and arguments will kick off the parsing and create a new :class:`Context`. It does not invoke the actual command callback though. :param info_name: the info name for this invokation. Generally this is the most descriptive name fo...
This function when given an info name and arguments will kick off the parsing and create a new :class:`Context`. It does not invoke the actual command callback though.
def make_context(self, info_name, args, parent=None, **extra): """This function when given an info name and arguments will kick off the parsing and create a new :class:`Context`. It does not invoke the actual command callback though. :param info_name: the info name for this invokation....
[ "def", "make_context", "(", "self", ",", "info_name", ",", "args", ",", "parent", "=", "None", ",", "*", "*", "extra", ")", ":", "for", "key", ",", "value", "in", "iteritems", "(", "self", ".", "context_settings", ")", ":", "if", "key", "not", "in", ...
[ 620, 4 ]
[ 641, 18 ]
python
en
['en', 'en', 'en']
True
BaseCommand.parse_args
(self, ctx, args)
Given a context and a list of arguments this creates the parser and parses the arguments, then modifies the context as necessary. This is automatically invoked by :meth:`make_context`.
Given a context and a list of arguments this creates the parser and parses the arguments, then modifies the context as necessary. This is automatically invoked by :meth:`make_context`.
def parse_args(self, ctx, args): """Given a context and a list of arguments this creates the parser and parses the arguments, then modifies the context as necessary. This is automatically invoked by :meth:`make_context`. """ raise NotImplementedError('Base commands do not know ho...
[ "def", "parse_args", "(", "self", ",", "ctx", ",", "args", ")", ":", "raise", "NotImplementedError", "(", "'Base commands do not know how to parse '", "'arguments.'", ")" ]
[ 643, 4 ]
[ 649, 47 ]
python
en
['en', 'en', 'en']
True
BaseCommand.invoke
(self, ctx)
Given a context, this invokes the command. The default implementation is raising a not implemented error.
Given a context, this invokes the command. The default implementation is raising a not implemented error.
def invoke(self, ctx): """Given a context, this invokes the command. The default implementation is raising a not implemented error. """ raise NotImplementedError('Base commands are not invokable by default')
[ "def", "invoke", "(", "self", ",", "ctx", ")", ":", "raise", "NotImplementedError", "(", "'Base commands are not invokable by default'", ")" ]
[ 651, 4 ]
[ 655, 79 ]
python
en
['en', 'en', 'en']
True
BaseCommand.main
(self, args=None, prog_name=None, complete_var=None, standalone_mode=True, **extra)
This is the way to invoke a script with all the bells and whistles as a command line application. This will always terminate the application after a call. If this is not wanted, ``SystemExit`` needs to be caught. This method is also available by directly calling the instance of ...
This is the way to invoke a script with all the bells and whistles as a command line application. This will always terminate the application after a call. If this is not wanted, ``SystemExit`` needs to be caught.
def main(self, args=None, prog_name=None, complete_var=None, standalone_mode=True, **extra): """This is the way to invoke a script with all the bells and whistles as a command line application. This will always terminate the application after a call. If this is not wanted, ``Syste...
[ "def", "main", "(", "self", ",", "args", "=", "None", ",", "prog_name", "=", "None", ",", "complete_var", "=", "None", ",", "standalone_mode", "=", "True", ",", "*", "*", "extra", ")", ":", "# If we are in Python 3, we will verify that the environment is", "# sa...
[ 657, 4 ]
[ 759, 23 ]
python
en
['en', 'en', 'en']
True
BaseCommand.__call__
(self, *args, **kwargs)
Alias for :meth:`main`.
Alias for :meth:`main`.
def __call__(self, *args, **kwargs): """Alias for :meth:`main`.""" return self.main(*args, **kwargs)
[ "def", "__call__", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "main", "(", "*", "args", ",", "*", "*", "kwargs", ")" ]
[ 761, 4 ]
[ 763, 41 ]
python
en
['es', 'hmn', 'en']
False
Command.format_usage
(self, ctx, formatter)
Writes the usage line into the formatter.
Writes the usage line into the formatter.
def format_usage(self, ctx, formatter): """Writes the usage line into the formatter.""" pieces = self.collect_usage_pieces(ctx) formatter.write_usage(ctx.command_path, ' '.join(pieces))
[ "def", "format_usage", "(", "self", ",", "ctx", ",", "formatter", ")", ":", "pieces", "=", "self", ".", "collect_usage_pieces", "(", "ctx", ")", "formatter", ".", "write_usage", "(", "ctx", ".", "command_path", ",", "' '", ".", "join", "(", "pieces", ")"...
[ 829, 4 ]
[ 832, 65 ]
python
en
['en', 'en', 'en']
True
Command.collect_usage_pieces
(self, ctx)
Returns all the pieces that go into the usage line and returns it as a list of strings.
Returns all the pieces that go into the usage line and returns it as a list of strings.
def collect_usage_pieces(self, ctx): """Returns all the pieces that go into the usage line and returns it as a list of strings. """ rv = [self.options_metavar] for param in self.get_params(ctx): rv.extend(param.get_usage_pieces(ctx)) return rv
[ "def", "collect_usage_pieces", "(", "self", ",", "ctx", ")", ":", "rv", "=", "[", "self", ".", "options_metavar", "]", "for", "param", "in", "self", ".", "get_params", "(", "ctx", ")", ":", "rv", ".", "extend", "(", "param", ".", "get_usage_pieces", "(...
[ 834, 4 ]
[ 841, 17 ]
python
en
['en', 'en', 'en']
True
Command.get_help_option_names
(self, ctx)
Returns the names for the help option.
Returns the names for the help option.
def get_help_option_names(self, ctx): """Returns the names for the help option.""" all_names = set(ctx.help_option_names) for param in self.params: all_names.difference_update(param.opts) all_names.difference_update(param.secondary_opts) return all_names
[ "def", "get_help_option_names", "(", "self", ",", "ctx", ")", ":", "all_names", "=", "set", "(", "ctx", ".", "help_option_names", ")", "for", "param", "in", "self", ".", "params", ":", "all_names", ".", "difference_update", "(", "param", ".", "opts", ")", ...
[ 843, 4 ]
[ 849, 24 ]
python
en
['en', 'en', 'en']
True
Command.get_help_option
(self, ctx)
Returns the help option object.
Returns the help option object.
def get_help_option(self, ctx): """Returns the help option object.""" help_options = self.get_help_option_names(ctx) if not help_options or not self.add_help_option: return def show_help(ctx, param, value): if value and not ctx.resilient_parsing: ...
[ "def", "get_help_option", "(", "self", ",", "ctx", ")", ":", "help_options", "=", "self", ".", "get_help_option_names", "(", "ctx", ")", "if", "not", "help_options", "or", "not", "self", ".", "add_help_option", ":", "return", "def", "show_help", "(", "ctx", ...
[ 851, 4 ]
[ 864, 57 ]
python
en
['en', 'en', 'en']
True
Command.make_parser
(self, ctx)
Creates the underlying option parser for this command.
Creates the underlying option parser for this command.
def make_parser(self, ctx): """Creates the underlying option parser for this command.""" parser = OptionParser(ctx) for param in self.get_params(ctx): param.add_to_parser(parser, ctx) return parser
[ "def", "make_parser", "(", "self", ",", "ctx", ")", ":", "parser", "=", "OptionParser", "(", "ctx", ")", "for", "param", "in", "self", ".", "get_params", "(", "ctx", ")", ":", "param", ".", "add_to_parser", "(", "parser", ",", "ctx", ")", "return", "...
[ 866, 4 ]
[ 871, 21 ]
python
en
['en', 'en', 'en']
True
Command.get_help
(self, ctx)
Formats the help into a string and returns it. This creates a formatter and will call into the following formatting methods:
Formats the help into a string and returns it. This creates a formatter and will call into the following formatting methods:
def get_help(self, ctx): """Formats the help into a string and returns it. This creates a formatter and will call into the following formatting methods: """ formatter = ctx.make_formatter() self.format_help(ctx, formatter) return formatter.getvalue().rstrip('\n')
[ "def", "get_help", "(", "self", ",", "ctx", ")", ":", "formatter", "=", "ctx", ".", "make_formatter", "(", ")", "self", ".", "format_help", "(", "ctx", ",", "formatter", ")", "return", "formatter", ".", "getvalue", "(", ")", ".", "rstrip", "(", "'\\n'"...
[ 873, 4 ]
[ 879, 48 ]
python
en
['en', 'en', 'en']
True
Command.get_short_help_str
(self, limit=45)
Gets short help for the command or makes it by shortening the long help string.
Gets short help for the command or makes it by shortening the long help string.
def get_short_help_str(self, limit=45): """Gets short help for the command or makes it by shortening the long help string.""" return self.short_help or self.help and make_default_short_help(self.help, limit) or ''
[ "def", "get_short_help_str", "(", "self", ",", "limit", "=", "45", ")", ":", "return", "self", ".", "short_help", "or", "self", ".", "help", "and", "make_default_short_help", "(", "self", ".", "help", ",", "limit", ")", "or", "''" ]
[ 881, 4 ]
[ 883, 95 ]
python
en
['en', 'en', 'en']
True
Command.format_help
(self, ctx, formatter)
Writes the help into the formatter if it exists. This calls into the following methods: - :meth:`format_usage` - :meth:`format_help_text` - :meth:`format_options` - :meth:`format_epilog`
Writes the help into the formatter if it exists.
def format_help(self, ctx, formatter): """Writes the help into the formatter if it exists. This calls into the following methods: - :meth:`format_usage` - :meth:`format_help_text` - :meth:`format_options` - :meth:`format_epilog` """ self.format_u...
[ "def", "format_help", "(", "self", ",", "ctx", ",", "formatter", ")", ":", "self", ".", "format_usage", "(", "ctx", ",", "formatter", ")", "self", ".", "format_help_text", "(", "ctx", ",", "formatter", ")", "self", ".", "format_options", "(", "ctx", ",",...
[ 885, 4 ]
[ 898, 42 ]
python
en
['en', 'en', 'en']
True
Command.format_help_text
(self, ctx, formatter)
Writes the help text to the formatter if it exists.
Writes the help text to the formatter if it exists.
def format_help_text(self, ctx, formatter): """Writes the help text to the formatter if it exists.""" if self.help: formatter.write_paragraph() with formatter.indentation(): help_text = self.help if self.deprecated: help_text +=...
[ "def", "format_help_text", "(", "self", ",", "ctx", ",", "formatter", ")", ":", "if", "self", ".", "help", ":", "formatter", ".", "write_paragraph", "(", ")", "with", "formatter", ".", "indentation", "(", ")", ":", "help_text", "=", "self", ".", "help", ...
[ 900, 4 ]
[ 912, 60 ]
python
en
['en', 'en', 'en']
True
Command.format_options
(self, ctx, formatter)
Writes all the options into the formatter if they exist.
Writes all the options into the formatter if they exist.
def format_options(self, ctx, formatter): """Writes all the options into the formatter if they exist.""" opts = [] for param in self.get_params(ctx): rv = param.get_help_record(ctx) if rv is not None: opts.append(rv) if opts: with form...
[ "def", "format_options", "(", "self", ",", "ctx", ",", "formatter", ")", ":", "opts", "=", "[", "]", "for", "param", "in", "self", ".", "get_params", "(", "ctx", ")", ":", "rv", "=", "param", ".", "get_help_record", "(", "ctx", ")", "if", "rv", "is...
[ 914, 4 ]
[ 924, 40 ]
python
en
['en', 'en', 'en']
True
Command.format_epilog
(self, ctx, formatter)
Writes the epilog into the formatter if it exists.
Writes the epilog into the formatter if it exists.
def format_epilog(self, ctx, formatter): """Writes the epilog into the formatter if it exists.""" if self.epilog: formatter.write_paragraph() with formatter.indentation(): formatter.write_text(self.epilog)
[ "def", "format_epilog", "(", "self", ",", "ctx", ",", "formatter", ")", ":", "if", "self", ".", "epilog", ":", "formatter", ".", "write_paragraph", "(", ")", "with", "formatter", ".", "indentation", "(", ")", ":", "formatter", ".", "write_text", "(", "se...
[ 926, 4 ]
[ 931, 49 ]
python
en
['en', 'en', 'en']
True
Command.invoke
(self, ctx)
Given a context, this invokes the attached callback (if it exists) in the right way.
Given a context, this invokes the attached callback (if it exists) in the right way.
def invoke(self, ctx): """Given a context, this invokes the attached callback (if it exists) in the right way. """ _maybe_show_deprecated_notice(self) if self.callback is not None: return ctx.invoke(self.callback, **ctx.params)
[ "def", "invoke", "(", "self", ",", "ctx", ")", ":", "_maybe_show_deprecated_notice", "(", "self", ")", "if", "self", ".", "callback", "is", "not", "None", ":", "return", "ctx", ".", "invoke", "(", "self", ".", "callback", ",", "*", "*", "ctx", ".", "...
[ 949, 4 ]
[ 955, 58 ]
python
en
['en', 'en', 'en']
True
MultiCommand.resultcallback
(self, replace=False)
Adds a result callback to the chain command. By default if a result callback is already registered this will chain them but this can be disabled with the `replace` parameter. The result callback is invoked with the return value of the subcommand (or the list of return values from all s...
Adds a result callback to the chain command. By default if a result callback is already registered this will chain them but this can be disabled with the `replace` parameter. The result callback is invoked with the return value of the subcommand (or the list of return values from all s...
def resultcallback(self, replace=False): """Adds a result callback to the chain command. By default if a result callback is already registered this will chain them but this can be disabled with the `replace` parameter. The result callback is invoked with the return value of the subcomm...
[ "def", "resultcallback", "(", "self", ",", "replace", "=", "False", ")", ":", "def", "decorator", "(", "f", ")", ":", "old_callback", "=", "self", ".", "result_callback", "if", "old_callback", "is", "None", "or", "replace", ":", "self", ".", "result_callba...
[ 1018, 4 ]
[ 1053, 24 ]
python
en
['en', 'en', 'en']
True
MultiCommand.format_commands
(self, ctx, formatter)
Extra format methods for multi methods that adds all the commands after the options.
Extra format methods for multi methods that adds all the commands after the options.
def format_commands(self, ctx, formatter): """Extra format methods for multi methods that adds all the commands after the options. """ commands = [] for subcommand in self.list_commands(ctx): cmd = self.get_command(ctx, subcommand) # What is this, the tool...
[ "def", "format_commands", "(", "self", ",", "ctx", ",", "formatter", ")", ":", "commands", "=", "[", "]", "for", "subcommand", "in", "self", ".", "list_commands", "(", "ctx", ")", ":", "cmd", "=", "self", ".", "get_command", "(", "ctx", ",", "subcomman...
[ 1055, 4 ]
[ 1081, 44 ]
python
en
['en', 'en', 'en']
True
MultiCommand.get_command
(self, ctx, cmd_name)
Given a context and a command name, this returns a :class:`Command` object if it exists or returns `None`.
Given a context and a command name, this returns a :class:`Command` object if it exists or returns `None`.
def get_command(self, ctx, cmd_name): """Given a context and a command name, this returns a :class:`Command` object if it exists or returns `None`. """ raise NotImplementedError()
[ "def", "get_command", "(", "self", ",", "ctx", ",", "cmd_name", ")", ":", "raise", "NotImplementedError", "(", ")" ]
[ 1191, 4 ]
[ 1195, 35 ]
python
en
['en', 'en', 'en']
True
MultiCommand.list_commands
(self, ctx)
Returns a list of subcommand names in the order they should appear.
Returns a list of subcommand names in the order they should appear.
def list_commands(self, ctx): """Returns a list of subcommand names in the order they should appear. """ return []
[ "def", "list_commands", "(", "self", ",", "ctx", ")", ":", "return", "[", "]" ]
[ 1197, 4 ]
[ 1201, 17 ]
python
en
['en', 'en', 'en']
True
Group.add_command
(self, cmd, name=None)
Registers another :class:`Command` with this group. If the name is not provided, the name of the command is used.
Registers another :class:`Command` with this group. If the name is not provided, the name of the command is used.
def add_command(self, cmd, name=None): """Registers another :class:`Command` with this group. If the name is not provided, the name of the command is used. """ name = name or cmd.name if name is None: raise TypeError('Command has no name.') _check_multicomman...
[ "def", "add_command", "(", "self", ",", "cmd", ",", "name", "=", "None", ")", ":", "name", "=", "name", "or", "cmd", ".", "name", "if", "name", "is", "None", ":", "raise", "TypeError", "(", "'Command has no name.'", ")", "_check_multicommand", "(", "self...
[ 1216, 4 ]
[ 1224, 33 ]
python
en
['en', 'en', 'en']
True
Group.command
(self, *args, **kwargs)
A shortcut decorator for declaring and attaching a command to the group. This takes the same arguments as :func:`command` but immediately registers the created command with this instance by calling into :meth:`add_command`.
A shortcut decorator for declaring and attaching a command to the group. This takes the same arguments as :func:`command` but immediately registers the created command with this instance by calling into :meth:`add_command`.
def command(self, *args, **kwargs): """A shortcut decorator for declaring and attaching a command to the group. This takes the same arguments as :func:`command` but immediately registers the created command with this instance by calling into :meth:`add_command`. """ def ...
[ "def", "command", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "decorator", "(", "f", ")", ":", "cmd", "=", "command", "(", "*", "args", ",", "*", "*", "kwargs", ")", "(", "f", ")", "self", ".", "add_command", "(", ...
[ 1226, 4 ]
[ 1236, 24 ]
python
en
['en', 'en', 'en']
True
Group.group
(self, *args, **kwargs)
A shortcut decorator for declaring and attaching a group to the group. This takes the same arguments as :func:`group` but immediately registers the created command with this instance by calling into :meth:`add_command`.
A shortcut decorator for declaring and attaching a group to the group. This takes the same arguments as :func:`group` but immediately registers the created command with this instance by calling into :meth:`add_command`.
def group(self, *args, **kwargs): """A shortcut decorator for declaring and attaching a group to the group. This takes the same arguments as :func:`group` but immediately registers the created command with this instance by calling into :meth:`add_command`. """ def decora...
[ "def", "group", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "decorator", "(", "f", ")", ":", "cmd", "=", "group", "(", "*", "args", ",", "*", "*", "kwargs", ")", "(", "f", ")", "self", ".", "add_command", "(", "cm...
[ 1238, 4 ]
[ 1248, 24 ]
python
en
['en', 'en', 'en']
True
CommandCollection.add_source
(self, multi_cmd)
Adds a new multi command to the chain dispatcher.
Adds a new multi command to the chain dispatcher.
def add_source(self, multi_cmd): """Adds a new multi command to the chain dispatcher.""" self.sources.append(multi_cmd)
[ "def", "add_source", "(", "self", ",", "multi_cmd", ")", ":", "self", ".", "sources", ".", "append", "(", "multi_cmd", ")" ]
[ 1269, 4 ]
[ 1271, 38 ]
python
en
['en', 'en', 'en']
True
Parameter.human_readable_name
(self)
Returns the human readable name of this parameter. This is the same as the name for options, but the metavar for arguments.
Returns the human readable name of this parameter. This is the same as the name for options, but the metavar for arguments.
def human_readable_name(self): """Returns the human readable name of this parameter. This is the same as the name for options, but the metavar for arguments. """ return self.name
[ "def", "human_readable_name", "(", "self", ")", ":", "return", "self", ".", "name" ]
[ 1361, 4 ]
[ 1365, 24 ]
python
en
['en', 'en', 'en']
True
Parameter.get_default
(self, ctx)
Given a context variable this calculates the default value.
Given a context variable this calculates the default value.
def get_default(self, ctx): """Given a context variable this calculates the default value.""" # Otherwise go with the regular default. if callable(self.default): rv = self.default() else: rv = self.default return self.type_cast_value(ctx, rv)
[ "def", "get_default", "(", "self", ",", "ctx", ")", ":", "# Otherwise go with the regular default.", "if", "callable", "(", "self", ".", "default", ")", ":", "rv", "=", "self", ".", "default", "(", ")", "else", ":", "rv", "=", "self", ".", "default", "re...
[ 1377, 4 ]
[ 1384, 44 ]
python
en
['en', 'en', 'en']
True
Parameter.type_cast_value
(self, ctx, value)
Given a value this runs it properly through the type system. This automatically handles things like `nargs` and `multiple` as well as composite types.
Given a value this runs it properly through the type system. This automatically handles things like `nargs` and `multiple` as well as composite types.
def type_cast_value(self, ctx, value): """Given a value this runs it properly through the type system. This automatically handles things like `nargs` and `multiple` as well as composite types. """ if self.type.is_composite: if self.nargs <= 1: raise Ty...
[ "def", "type_cast_value", "(", "self", ",", "ctx", ",", "value", ")", ":", "if", "self", ".", "type", ".", "is_composite", ":", "if", "self", ".", "nargs", "<=", "1", ":", "raise", "TypeError", "(", "'Attempted to invoke composite type '", "'but nargs has been...
[ 1397, 4 ]
[ 1416, 71 ]
python
en
['en', 'en', 'en']
True
Parameter.process_value
(self, ctx, value)
Given a value and context this runs the logic to convert the value as necessary.
Given a value and context this runs the logic to convert the value as necessary.
def process_value(self, ctx, value): """Given a value and context this runs the logic to convert the value as necessary. """ # If the value we were given is None we do nothing. This way # code that calls this can easily figure out if something was # not provided. Otherw...
[ "def", "process_value", "(", "self", ",", "ctx", ",", "value", ")", ":", "# If the value we were given is None we do nothing. This way", "# code that calls this can easily figure out if something was", "# not provided. Otherwise it would be converted into an empty", "# tuple for multiple...
[ 1418, 4 ]
[ 1427, 51 ]
python
en
['en', 'en', 'en']
True
Parameter.get_error_hint
(self, ctx)
Get a stringified version of the param for use in error messages to indicate which param caused the error.
Get a stringified version of the param for use in error messages to indicate which param caused the error.
def get_error_hint(self, ctx): """Get a stringified version of the param for use in error messages to indicate which param caused the error. """ hint_list = self.opts or [self.human_readable_name] return ' / '.join('"%s"' % x for x in hint_list)
[ "def", "get_error_hint", "(", "self", ",", "ctx", ")", ":", "hint_list", "=", "self", ".", "opts", "or", "[", "self", ".", "human_readable_name", "]", "return", "' / '", ".", "join", "(", "'\"%s\"'", "%", "x", "for", "x", "in", "hint_list", ")" ]
[ 1491, 4 ]
[ 1496, 56 ]
python
en
['en', 'en', 'en']
True
Option.prompt_for_value
(self, ctx)
This is an alternative flow that can be activated in the full value processing if a value does not exist. It will prompt the user until a valid value exists and then returns the processed value as result.
This is an alternative flow that can be activated in the full value processing if a value does not exist. It will prompt the user until a valid value exists and then returns the processed value as result.
def prompt_for_value(self, ctx): """This is an alternative flow that can be activated in the full value processing if a value does not exist. It will prompt the user until a valid value exists and then returns the processed value as result. """ # Calculate the default be...
[ "def", "prompt_for_value", "(", "self", ",", "ctx", ")", ":", "# Calculate the default before prompting anything to be stable.", "default", "=", "self", ".", "get_default", "(", "ctx", ")", "# If this is a prompt for a flag we need to handle this", "# differently.", "if", "se...
[ 1746, 4 ]
[ 1763, 70 ]
python
en
['en', 'en', 'en']
True
transform_hits
(hits: List[Dict[str, str]])
The list from pypi is really a list of versions. We want a list of packages with the list of versions stored inline. This converts the list from pypi into one we can use.
The list from pypi is really a list of versions. We want a list of packages with the list of versions stored inline. This converts the list from pypi into one we can use.
def transform_hits(hits: List[Dict[str, str]]) -> List["TransformedHit"]: """ The list from pypi is really a list of versions. We want a list of packages with the list of versions stored inline. This converts the list from pypi into one we can use. """ packages: Dict[str, "TransformedHit"] = Ord...
[ "def", "transform_hits", "(", "hits", ":", "List", "[", "Dict", "[", "str", ",", "str", "]", "]", ")", "->", "List", "[", "\"TransformedHit\"", "]", ":", "packages", ":", "Dict", "[", "str", ",", "\"TransformedHit\"", "]", "=", "OrderedDict", "(", ")",...
[ 84, 0 ]
[ 109, 34 ]
python
en
['en', 'error', 'th']
False
dispatch_hook
(key, hooks, hook_data, **kwargs)
Dispatches a hook dictionary on a given piece of data.
Dispatches a hook dictionary on a given piece of data.
def dispatch_hook(key, hooks, hook_data, **kwargs): """Dispatches a hook dictionary on a given piece of data.""" hooks = hooks or {} hooks = hooks.get(key) if hooks: if hasattr(hooks, '__call__'): hooks = [hooks] for hook in hooks: _hook_data = hook(hook_data, **k...
[ "def", "dispatch_hook", "(", "key", ",", "hooks", ",", "hook_data", ",", "*", "*", "kwargs", ")", ":", "hooks", "=", "hooks", "or", "{", "}", "hooks", "=", "hooks", ".", "get", "(", "key", ")", "if", "hooks", ":", "if", "hasattr", "(", "hooks", "...
[ 22, 0 ]
[ 33, 20 ]
python
en
['en', 'en', 'en']
True
_error
(msg)
Print msg and optionally exit with return code exit_.
Print msg and optionally exit with return code exit_.
def _error(msg): """Print msg and optionally exit with return code exit_.""" sys.stderr.write('[ERROR] {}\n'.format(msg)) return 1
[ "def", "_error", "(", "msg", ")", ":", "sys", ".", "stderr", ".", "write", "(", "'[ERROR] {}\\n'", ".", "format", "(", "msg", ")", ")", "return", "1" ]
[ 150, 0 ]
[ 153, 12 ]
python
en
['en', 'en', 'en']
True
normalize_eols
(raw_contents)
Take a block of raw text that will be passed through str.splitlines() to get universal newlines treatment. Return the resulting block of text with normalized `\n` EOL sequences ready to be written to disk using current platform's native EOLs.
Take a block of raw text that will be passed through str.splitlines() to get universal newlines treatment.
def normalize_eols(raw_contents): """ Take a block of raw text that will be passed through str.splitlines() to get universal newlines treatment. Return the resulting block of text with normalized `\n` EOL sequences ready to be written to disk using current platform's native EOLs. """ lines_...
[ "def", "normalize_eols", "(", "raw_contents", ")", ":", "lines_list", "=", "raw_contents", ".", "splitlines", "(", ")", "# Ensure last line has its EOL", "if", "lines_list", "and", "lines_list", "[", "-", "1", "]", ":", "lines_list", ".", "append", "(", "''", ...
[ 154, 0 ]
[ 166, 32 ]
python
en
['en', 'error', 'th']
False
write_pot_file
(potfile, msgs)
Write the `potfile` with the `msgs` contents, making sure its format is valid.
Write the `potfile` with the `msgs` contents, making sure its format is valid.
def write_pot_file(potfile, msgs): """ Write the `potfile` with the `msgs` contents, making sure its format is valid. """ pot_lines = msgs.splitlines() if os.path.exists(potfile): # Strip the header lines = dropwhile(len, pot_lines) else: lines = [] found, hea...
[ "def", "write_pot_file", "(", "potfile", ",", "msgs", ")", ":", "pot_lines", "=", "msgs", ".", "splitlines", "(", ")", "if", "os", ".", "path", ".", "exists", "(", "potfile", ")", ":", "# Strip the header", "lines", "=", "dropwhile", "(", "len", ",", "...
[ 169, 0 ]
[ 193, 22 ]
python
en
['en', 'error', 'th']
False
BuildFile.work_path
(self)
Path to a file which is being fed into GNU gettext pipeline. This may be either a translatable or its preprocessed version.
Path to a file which is being fed into GNU gettext pipeline. This may be either a translatable or its preprocessed version.
def work_path(self): """ Path to a file which is being fed into GNU gettext pipeline. This may be either a translatable or its preprocessed version. """ if not self.is_templatized: return self.path extension = { 'djangojs': 'c', 'django...
[ "def", "work_path", "(", "self", ")", ":", "if", "not", "self", ".", "is_templatized", ":", "return", "self", ".", "path", "extension", "=", "{", "'djangojs'", ":", "'c'", ",", "'django'", ":", "'py'", ",", "}", ".", "get", "(", "self", ".", "domain"...
[ 83, 4 ]
[ 95, 64 ]
python
en
['en', 'error', 'th']
False
BuildFile.preprocess
(self)
Preprocess (if necessary) a translatable file before passing it to xgettext GNU gettext utility.
Preprocess (if necessary) a translatable file before passing it to xgettext GNU gettext utility.
def preprocess(self): """ Preprocess (if necessary) a translatable file before passing it to xgettext GNU gettext utility. """ if not self.is_templatized: return with open(self.path, encoding='utf-8') as fp: src_data = fp.read() if self.d...
[ "def", "preprocess", "(", "self", ")", ":", "if", "not", "self", ".", "is_templatized", ":", "return", "with", "open", "(", "self", ".", "path", ",", "encoding", "=", "'utf-8'", ")", "as", "fp", ":", "src_data", "=", "fp", ".", "read", "(", ")", "i...
[ 97, 4 ]
[ 114, 29 ]
python
en
['en', 'error', 'th']
False
BuildFile.postprocess_messages
(self, msgs)
Postprocess messages generated by xgettext GNU gettext utility. Transform paths as if these messages were generated from original translatable files rather than from preprocessed versions.
Postprocess messages generated by xgettext GNU gettext utility.
def postprocess_messages(self, msgs): """ Postprocess messages generated by xgettext GNU gettext utility. Transform paths as if these messages were generated from original translatable files rather than from preprocessed versions. """ if not self.is_templatized: ...
[ "def", "postprocess_messages", "(", "self", ",", "msgs", ")", ":", "if", "not", "self", ".", "is_templatized", ":", "return", "msgs", "# Remove '.py' suffix", "if", "os", ".", "name", "==", "'nt'", ":", "# Preserve '.\\' prefix on Windows to respect gettext behavior",...
[ 116, 4 ]
[ 140, 9 ]
python
en
['en', 'error', 'th']
False
BuildFile.cleanup
(self)
Remove a preprocessed copy of a translatable file (if any).
Remove a preprocessed copy of a translatable file (if any).
def cleanup(self): """ Remove a preprocessed copy of a translatable file (if any). """ if self.is_templatized: # This check is needed for the case of a symlinked file and its # source being processed inside a single group (locale dir); # removing eithe...
[ "def", "cleanup", "(", "self", ")", ":", "if", "self", ".", "is_templatized", ":", "# This check is needed for the case of a symlinked file and its", "# source being processed inside a single group (locale dir);", "# removing either of those two removes both.", "if", "os", ".", "pa...
[ 142, 4 ]
[ 151, 41 ]
python
en
['en', 'error', 'th']
False
Command.build_potfiles
(self)
Build pot files and apply msguniq to them.
Build pot files and apply msguniq to them.
def build_potfiles(self): """ Build pot files and apply msguniq to them. """ file_list = self.find_files(".") self.remove_potfiles() self.process_files(file_list) potfiles = [] for path in self.locale_paths: potfile = os.path.join(path, '%s.pot...
[ "def", "build_potfiles", "(", "self", ")", ":", "file_list", "=", "self", ".", "find_files", "(", "\".\"", ")", "self", ".", "remove_potfiles", "(", ")", "self", ".", "process_files", "(", "file_list", ")", "potfiles", "=", "[", "]", "for", "path", "in",...
[ 425, 4 ]
[ 449, 23 ]
python
en
['en', 'error', 'th']
False
Command.find_files
(self, root)
Get all files in the given root. Also check that there is a matching locale dir for each file.
Get all files in the given root. Also check that there is a matching locale dir for each file.
def find_files(self, root): """ Get all files in the given root. Also check that there is a matching locale dir for each file. """ all_files = [] ignored_roots = [] if self.settings_available: ignored_roots = [os.path.normpath(p) for p in (settings.MED...
[ "def", "find_files", "(", "self", ",", "root", ")", ":", "all_files", "=", "[", "]", "ignored_roots", "=", "[", "]", "if", "self", ".", "settings_available", ":", "ignored_roots", "=", "[", "os", ".", "path", ".", "normpath", "(", "p", ")", "for", "p...
[ 457, 4 ]
[ 490, 32 ]
python
en
['en', 'error', 'th']
False
Command.process_files
(self, file_list)
Group translatable files by locale directory and run pot file build process for each group.
Group translatable files by locale directory and run pot file build process for each group.
def process_files(self, file_list): """ Group translatable files by locale directory and run pot file build process for each group. """ file_groups = {} for translatable in file_list: file_group = file_groups.setdefault(translatable.locale_dir, []) ...
[ "def", "process_files", "(", "self", ",", "file_list", ")", ":", "file_groups", "=", "{", "}", "for", "translatable", "in", "file_list", ":", "file_group", "=", "file_groups", ".", "setdefault", "(", "translatable", ".", "locale_dir", ",", "[", "]", ")", "...
[ 492, 4 ]
[ 502, 54 ]
python
en
['en', 'error', 'th']
False
Command.process_locale_dir
(self, locale_dir, files)
Extract translatable literals from the specified files, creating or updating the POT file for a given locale directory. Use the xgettext GNU gettext utility.
Extract translatable literals from the specified files, creating or updating the POT file for a given locale directory.
def process_locale_dir(self, locale_dir, files): """ Extract translatable literals from the specified files, creating or updating the POT file for a given locale directory. Use the xgettext GNU gettext utility. """ build_files = [] for translatable in files: ...
[ "def", "process_locale_dir", "(", "self", ",", "locale_dir", ",", "files", ")", ":", "build_files", "=", "[", "]", "for", "translatable", "in", "files", ":", "if", "self", ".", "verbosity", ">", "1", ":", "self", ".", "stdout", ".", "write", "(", "'pro...
[ 504, 4 ]
[ 597, 32 ]
python
en
['en', 'error', 'th']
False
Command.write_po_file
(self, potfile, locale)
Create or update the PO file for self.domain and `locale`. Use contents of the existing `potfile`. Use msgmerge and msgattrib GNU gettext utilities.
Create or update the PO file for self.domain and `locale`. Use contents of the existing `potfile`.
def write_po_file(self, potfile, locale): """ Create or update the PO file for self.domain and `locale`. Use contents of the existing `potfile`. Use msgmerge and msgattrib GNU gettext utilities. """ basedir = os.path.join(os.path.dirname(potfile), locale, 'LC_MESSAGES') ...
[ "def", "write_po_file", "(", "self", ",", "potfile", ",", "locale", ")", ":", "basedir", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "potfile", ")", ",", "locale", ",", "'LC_MESSAGES'", ")", "os", ".", "makedirs"...
[ 599, 4 ]
[ 638, 45 ]
python
en
['en', 'error', 'th']
False
Command.copy_plural_forms
(self, msgs, locale)
Copy plural forms header contents from a Django catalog of locale to the msgs string, inserting it at the right place. msgs should be the contents of a newly created .po file.
Copy plural forms header contents from a Django catalog of locale to the msgs string, inserting it at the right place. msgs should be the contents of a newly created .po file.
def copy_plural_forms(self, msgs, locale): """ Copy plural forms header contents from a Django catalog of locale to the msgs string, inserting it at the right place. msgs should be the contents of a newly created .po file. """ django_dir = os.path.normpath(os.path.join(os...
[ "def", "copy_plural_forms", "(", "self", ",", "msgs", ",", "locale", ")", ":", "django_dir", "=", "os", ".", "path", ".", "normpath", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "django", ".", "__file__", ")", ...
[ 640, 4 ]
[ 669, 19 ]
python
en
['en', 'error', 'th']
False
get_intersect_with_zero
(o, g)
Intersects a given gaze ray (origin o and direction g) with z = 0.
Intersects a given gaze ray (origin o and direction g) with z = 0.
def get_intersect_with_zero(o, g): """Intersects a given gaze ray (origin o and direction g) with z = 0.""" global nn_plane_normal, nn_plane_other if nn_plane_normal is None: nn_plane_normal = torch.tensor([0, 0, 1], dtype=torch.float32, device=device).view(1, 3, 1) nn_plane_other = torch.te...
[ "def", "get_intersect_with_zero", "(", "o", ",", "g", ")", ":", "global", "nn_plane_normal", ",", "nn_plane_other", "if", "nn_plane_normal", "is", "None", ":", "nn_plane_normal", "=", "torch", ".", "tensor", "(", "[", "0", ",", "0", ",", "1", "]", ",", "...
[ 108, 0 ]
[ 125, 42 ]
python
en
['en', 'en', 'en']
True