repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
sequence
docstring
stringlengths
3
17.3k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
basho/riak-python-client
riak/codecs/http.py
HttpCodec._normalize_json_search_response
def _normalize_json_search_response(self, json): """ Normalizes a JSON search response so that PB and HTTP have the same return value """ result = {} if 'facet_counts' in json: result['facet_counts'] = json[u'facet_counts'] if 'grouped' in json: result['grouped'] = json[u'grouped'] if 'stats' in json: result['stats'] = json[u'stats'] if u'response' in json: result['num_found'] = json[u'response'][u'numFound'] result['max_score'] = float(json[u'response'][u'maxScore']) docs = [] for doc in json[u'response'][u'docs']: resdoc = {} if u'_yz_rk' in doc: # Is this a Riak 2.0 result? resdoc = doc else: # Riak Search 1.0 Legacy assumptions about format resdoc[u'id'] = doc[u'id'] if u'fields' in doc: for k, v in six.iteritems(doc[u'fields']): resdoc[k] = v docs.append(resdoc) result['docs'] = docs return result
python
def _normalize_json_search_response(self, json): """ Normalizes a JSON search response so that PB and HTTP have the same return value """ result = {} if 'facet_counts' in json: result['facet_counts'] = json[u'facet_counts'] if 'grouped' in json: result['grouped'] = json[u'grouped'] if 'stats' in json: result['stats'] = json[u'stats'] if u'response' in json: result['num_found'] = json[u'response'][u'numFound'] result['max_score'] = float(json[u'response'][u'maxScore']) docs = [] for doc in json[u'response'][u'docs']: resdoc = {} if u'_yz_rk' in doc: # Is this a Riak 2.0 result? resdoc = doc else: # Riak Search 1.0 Legacy assumptions about format resdoc[u'id'] = doc[u'id'] if u'fields' in doc: for k, v in six.iteritems(doc[u'fields']): resdoc[k] = v docs.append(resdoc) result['docs'] = docs return result
[ "def", "_normalize_json_search_response", "(", "self", ",", "json", ")", ":", "result", "=", "{", "}", "if", "'facet_counts'", "in", "json", ":", "result", "[", "'facet_counts'", "]", "=", "json", "[", "u'facet_counts'", "]", "if", "'grouped'", "in", "json", ":", "result", "[", "'grouped'", "]", "=", "json", "[", "u'grouped'", "]", "if", "'stats'", "in", "json", ":", "result", "[", "'stats'", "]", "=", "json", "[", "u'stats'", "]", "if", "u'response'", "in", "json", ":", "result", "[", "'num_found'", "]", "=", "json", "[", "u'response'", "]", "[", "u'numFound'", "]", "result", "[", "'max_score'", "]", "=", "float", "(", "json", "[", "u'response'", "]", "[", "u'maxScore'", "]", ")", "docs", "=", "[", "]", "for", "doc", "in", "json", "[", "u'response'", "]", "[", "u'docs'", "]", ":", "resdoc", "=", "{", "}", "if", "u'_yz_rk'", "in", "doc", ":", "# Is this a Riak 2.0 result?", "resdoc", "=", "doc", "else", ":", "# Riak Search 1.0 Legacy assumptions about format", "resdoc", "[", "u'id'", "]", "=", "doc", "[", "u'id'", "]", "if", "u'fields'", "in", "doc", ":", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "doc", "[", "u'fields'", "]", ")", ":", "resdoc", "[", "k", "]", "=", "v", "docs", ".", "append", "(", "resdoc", ")", "result", "[", "'docs'", "]", "=", "docs", "return", "result" ]
Normalizes a JSON search response so that PB and HTTP have the same return value
[ "Normalizes", "a", "JSON", "search", "response", "so", "that", "PB", "and", "HTTP", "have", "the", "same", "return", "value" ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/codecs/http.py#L223-L252
train
basho/riak-python-client
riak/codecs/http.py
HttpCodec._normalize_xml_search_response
def _normalize_xml_search_response(self, xml): """ Normalizes an XML search response so that PB and HTTP have the same return value """ target = XMLSearchResult() parser = ElementTree.XMLParser(target=target) parser.feed(xml) return parser.close()
python
def _normalize_xml_search_response(self, xml): """ Normalizes an XML search response so that PB and HTTP have the same return value """ target = XMLSearchResult() parser = ElementTree.XMLParser(target=target) parser.feed(xml) return parser.close()
[ "def", "_normalize_xml_search_response", "(", "self", ",", "xml", ")", ":", "target", "=", "XMLSearchResult", "(", ")", "parser", "=", "ElementTree", ".", "XMLParser", "(", "target", "=", "target", ")", "parser", ".", "feed", "(", "xml", ")", "return", "parser", ".", "close", "(", ")" ]
Normalizes an XML search response so that PB and HTTP have the same return value
[ "Normalizes", "an", "XML", "search", "response", "so", "that", "PB", "and", "HTTP", "have", "the", "same", "return", "value" ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/codecs/http.py#L254-L262
train
basho/riak-python-client
riak/transports/http/__init__.py
NoNagleHTTPConnection.connect
def connect(self): """ Set TCP_NODELAY on socket """ HTTPConnection.connect(self) self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
python
def connect(self): """ Set TCP_NODELAY on socket """ HTTPConnection.connect(self) self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
[ "def", "connect", "(", "self", ")", ":", "HTTPConnection", ".", "connect", "(", "self", ")", "self", ".", "sock", ".", "setsockopt", "(", "socket", ".", "IPPROTO_TCP", ",", "socket", ".", "TCP_NODELAY", ",", "1", ")" ]
Set TCP_NODELAY on socket
[ "Set", "TCP_NODELAY", "on", "socket" ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/http/__init__.py#L52-L57
train
basho/riak-python-client
riak/client/transport.py
RiakClientTransport._with_retries
def _with_retries(self, pool, fn): """ Performs the passed function with retries against the given pool. :param pool: the connection pool to use :type pool: Pool :param fn: the function to pass a transport :type fn: function """ skip_nodes = [] def _skip_bad_nodes(transport): return transport._node not in skip_nodes retry_count = self.retries - 1 first_try = True current_try = 0 while True: try: with pool.transaction( _filter=_skip_bad_nodes, yield_resource=True) as resource: transport = resource.object try: return fn(transport) except (IOError, HTTPException, ConnectionClosed) as e: resource.errored = True if _is_retryable(e): transport._node.error_rate.incr(1) skip_nodes.append(transport._node) if first_try: continue else: raise BadResource(e) else: raise except BadResource as e: if current_try < retry_count: resource.errored = True current_try += 1 continue else: # Re-raise the inner exception raise e.args[0] finally: first_try = False
python
def _with_retries(self, pool, fn): """ Performs the passed function with retries against the given pool. :param pool: the connection pool to use :type pool: Pool :param fn: the function to pass a transport :type fn: function """ skip_nodes = [] def _skip_bad_nodes(transport): return transport._node not in skip_nodes retry_count = self.retries - 1 first_try = True current_try = 0 while True: try: with pool.transaction( _filter=_skip_bad_nodes, yield_resource=True) as resource: transport = resource.object try: return fn(transport) except (IOError, HTTPException, ConnectionClosed) as e: resource.errored = True if _is_retryable(e): transport._node.error_rate.incr(1) skip_nodes.append(transport._node) if first_try: continue else: raise BadResource(e) else: raise except BadResource as e: if current_try < retry_count: resource.errored = True current_try += 1 continue else: # Re-raise the inner exception raise e.args[0] finally: first_try = False
[ "def", "_with_retries", "(", "self", ",", "pool", ",", "fn", ")", ":", "skip_nodes", "=", "[", "]", "def", "_skip_bad_nodes", "(", "transport", ")", ":", "return", "transport", ".", "_node", "not", "in", "skip_nodes", "retry_count", "=", "self", ".", "retries", "-", "1", "first_try", "=", "True", "current_try", "=", "0", "while", "True", ":", "try", ":", "with", "pool", ".", "transaction", "(", "_filter", "=", "_skip_bad_nodes", ",", "yield_resource", "=", "True", ")", "as", "resource", ":", "transport", "=", "resource", ".", "object", "try", ":", "return", "fn", "(", "transport", ")", "except", "(", "IOError", ",", "HTTPException", ",", "ConnectionClosed", ")", "as", "e", ":", "resource", ".", "errored", "=", "True", "if", "_is_retryable", "(", "e", ")", ":", "transport", ".", "_node", ".", "error_rate", ".", "incr", "(", "1", ")", "skip_nodes", ".", "append", "(", "transport", ".", "_node", ")", "if", "first_try", ":", "continue", "else", ":", "raise", "BadResource", "(", "e", ")", "else", ":", "raise", "except", "BadResource", "as", "e", ":", "if", "current_try", "<", "retry_count", ":", "resource", ".", "errored", "=", "True", "current_try", "+=", "1", "continue", "else", ":", "# Re-raise the inner exception", "raise", "e", ".", "args", "[", "0", "]", "finally", ":", "first_try", "=", "False" ]
Performs the passed function with retries against the given pool. :param pool: the connection pool to use :type pool: Pool :param fn: the function to pass a transport :type fn: function
[ "Performs", "the", "passed", "function", "with", "retries", "against", "the", "given", "pool", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/transport.py#L143-L188
train
basho/riak-python-client
riak/client/transport.py
RiakClientTransport._choose_pool
def _choose_pool(self, protocol=None): """ Selects a connection pool according to the default protocol and the passed one. :param protocol: the protocol to use :type protocol: string :rtype: Pool """ if not protocol: protocol = self.protocol if protocol == 'http': pool = self._http_pool elif protocol == 'tcp' or protocol == 'pbc': pool = self._tcp_pool else: raise ValueError("invalid protocol %s" % protocol) if pool is None or self._closed: # NB: GH-500, this can happen if client is closed raise RuntimeError("Client is closed.") return pool
python
def _choose_pool(self, protocol=None): """ Selects a connection pool according to the default protocol and the passed one. :param protocol: the protocol to use :type protocol: string :rtype: Pool """ if not protocol: protocol = self.protocol if protocol == 'http': pool = self._http_pool elif protocol == 'tcp' or protocol == 'pbc': pool = self._tcp_pool else: raise ValueError("invalid protocol %s" % protocol) if pool is None or self._closed: # NB: GH-500, this can happen if client is closed raise RuntimeError("Client is closed.") return pool
[ "def", "_choose_pool", "(", "self", ",", "protocol", "=", "None", ")", ":", "if", "not", "protocol", ":", "protocol", "=", "self", ".", "protocol", "if", "protocol", "==", "'http'", ":", "pool", "=", "self", ".", "_http_pool", "elif", "protocol", "==", "'tcp'", "or", "protocol", "==", "'pbc'", ":", "pool", "=", "self", ".", "_tcp_pool", "else", ":", "raise", "ValueError", "(", "\"invalid protocol %s\"", "%", "protocol", ")", "if", "pool", "is", "None", "or", "self", ".", "_closed", ":", "# NB: GH-500, this can happen if client is closed", "raise", "RuntimeError", "(", "\"Client is closed.\"", ")", "return", "pool" ]
Selects a connection pool according to the default protocol and the passed one. :param protocol: the protocol to use :type protocol: string :rtype: Pool
[ "Selects", "a", "connection", "pool", "according", "to", "the", "default", "protocol", "and", "the", "passed", "one", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/transport.py#L190-L210
train
basho/riak-python-client
riak/client/__init__.py
default_encoder
def default_encoder(obj): """ Default encoder for JSON datatypes, which returns UTF-8 encoded json instead of the default bloated backslash u XXXX escaped ASCII strings. """ if isinstance(obj, bytes): return json.dumps(bytes_to_str(obj), ensure_ascii=False).encode("utf-8") else: return json.dumps(obj, ensure_ascii=False).encode("utf-8")
python
def default_encoder(obj): """ Default encoder for JSON datatypes, which returns UTF-8 encoded json instead of the default bloated backslash u XXXX escaped ASCII strings. """ if isinstance(obj, bytes): return json.dumps(bytes_to_str(obj), ensure_ascii=False).encode("utf-8") else: return json.dumps(obj, ensure_ascii=False).encode("utf-8")
[ "def", "default_encoder", "(", "obj", ")", ":", "if", "isinstance", "(", "obj", ",", "bytes", ")", ":", "return", "json", ".", "dumps", "(", "bytes_to_str", "(", "obj", ")", ",", "ensure_ascii", "=", "False", ")", ".", "encode", "(", "\"utf-8\"", ")", "else", ":", "return", "json", ".", "dumps", "(", "obj", ",", "ensure_ascii", "=", "False", ")", ".", "encode", "(", "\"utf-8\"", ")" ]
Default encoder for JSON datatypes, which returns UTF-8 encoded json instead of the default bloated backslash u XXXX escaped ASCII strings.
[ "Default", "encoder", "for", "JSON", "datatypes", "which", "returns", "UTF", "-", "8", "encoded", "json", "instead", "of", "the", "default", "bloated", "backslash", "u", "XXXX", "escaped", "ASCII", "strings", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/__init__.py#L37-L46
train
basho/riak-python-client
riak/client/__init__.py
RiakClient.close
def close(self): """ Iterate through all of the connections and close each one. """ if not self._closed: self._closed = True self._stop_multi_pools() if self._http_pool is not None: self._http_pool.clear() self._http_pool = None if self._tcp_pool is not None: self._tcp_pool.clear() self._tcp_pool = None
python
def close(self): """ Iterate through all of the connections and close each one. """ if not self._closed: self._closed = True self._stop_multi_pools() if self._http_pool is not None: self._http_pool.clear() self._http_pool = None if self._tcp_pool is not None: self._tcp_pool.clear() self._tcp_pool = None
[ "def", "close", "(", "self", ")", ":", "if", "not", "self", ".", "_closed", ":", "self", ".", "_closed", "=", "True", "self", ".", "_stop_multi_pools", "(", ")", "if", "self", ".", "_http_pool", "is", "not", "None", ":", "self", ".", "_http_pool", ".", "clear", "(", ")", "self", ".", "_http_pool", "=", "None", "if", "self", ".", "_tcp_pool", "is", "not", "None", ":", "self", ".", "_tcp_pool", ".", "clear", "(", ")", "self", ".", "_tcp_pool", "=", "None" ]
Iterate through all of the connections and close each one.
[ "Iterate", "through", "all", "of", "the", "connections", "and", "close", "each", "one", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/__init__.py#L319-L331
train
basho/riak-python-client
riak/client/__init__.py
RiakClient._create_credentials
def _create_credentials(self, n): """ Create security credentials, if necessary. """ if not n: return n elif isinstance(n, SecurityCreds): return n elif isinstance(n, dict): return SecurityCreds(**n) else: raise TypeError("%s is not a valid security configuration" % repr(n))
python
def _create_credentials(self, n): """ Create security credentials, if necessary. """ if not n: return n elif isinstance(n, SecurityCreds): return n elif isinstance(n, dict): return SecurityCreds(**n) else: raise TypeError("%s is not a valid security configuration" % repr(n))
[ "def", "_create_credentials", "(", "self", ",", "n", ")", ":", "if", "not", "n", ":", "return", "n", "elif", "isinstance", "(", "n", ",", "SecurityCreds", ")", ":", "return", "n", "elif", "isinstance", "(", "n", ",", "dict", ")", ":", "return", "SecurityCreds", "(", "*", "*", "n", ")", "else", ":", "raise", "TypeError", "(", "\"%s is not a valid security configuration\"", "%", "repr", "(", "n", ")", ")" ]
Create security credentials, if necessary.
[ "Create", "security", "credentials", "if", "necessary", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/client/__init__.py#L355-L367
train
basho/riak-python-client
riak/transports/http/connection.py
HttpConnection._connect
def _connect(self): """ Use the appropriate connection class; optionally with security. """ timeout = None if self._options is not None and 'timeout' in self._options: timeout = self._options['timeout'] if self._client._credentials: self._connection = self._connection_class( host=self._node.host, port=self._node.http_port, credentials=self._client._credentials, timeout=timeout) else: self._connection = self._connection_class( host=self._node.host, port=self._node.http_port, timeout=timeout) # Forces the population of stats and resources before any # other requests are made. self.server_version
python
def _connect(self): """ Use the appropriate connection class; optionally with security. """ timeout = None if self._options is not None and 'timeout' in self._options: timeout = self._options['timeout'] if self._client._credentials: self._connection = self._connection_class( host=self._node.host, port=self._node.http_port, credentials=self._client._credentials, timeout=timeout) else: self._connection = self._connection_class( host=self._node.host, port=self._node.http_port, timeout=timeout) # Forces the population of stats and resources before any # other requests are made. self.server_version
[ "def", "_connect", "(", "self", ")", ":", "timeout", "=", "None", "if", "self", ".", "_options", "is", "not", "None", "and", "'timeout'", "in", "self", ".", "_options", ":", "timeout", "=", "self", ".", "_options", "[", "'timeout'", "]", "if", "self", ".", "_client", ".", "_credentials", ":", "self", ".", "_connection", "=", "self", ".", "_connection_class", "(", "host", "=", "self", ".", "_node", ".", "host", ",", "port", "=", "self", ".", "_node", ".", "http_port", ",", "credentials", "=", "self", ".", "_client", ".", "_credentials", ",", "timeout", "=", "timeout", ")", "else", ":", "self", ".", "_connection", "=", "self", ".", "_connection_class", "(", "host", "=", "self", ".", "_node", ".", "host", ",", "port", "=", "self", ".", "_node", ".", "http_port", ",", "timeout", "=", "timeout", ")", "# Forces the population of stats and resources before any", "# other requests are made.", "self", ".", "server_version" ]
Use the appropriate connection class; optionally with security.
[ "Use", "the", "appropriate", "connection", "class", ";", "optionally", "with", "security", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/http/connection.py#L65-L86
train
basho/riak-python-client
riak/transports/http/connection.py
HttpConnection._security_auth_headers
def _security_auth_headers(self, username, password, headers): """ Add in the requisite HTTP Authentication Headers :param username: Riak Security Username :type str :param password: Riak Security Password :type str :param headers: Dictionary of headers :type dict """ userColonPassword = username + ":" + password b64UserColonPassword = base64. \ b64encode(str_to_bytes(userColonPassword)).decode("ascii") headers['Authorization'] = 'Basic %s' % b64UserColonPassword
python
def _security_auth_headers(self, username, password, headers): """ Add in the requisite HTTP Authentication Headers :param username: Riak Security Username :type str :param password: Riak Security Password :type str :param headers: Dictionary of headers :type dict """ userColonPassword = username + ":" + password b64UserColonPassword = base64. \ b64encode(str_to_bytes(userColonPassword)).decode("ascii") headers['Authorization'] = 'Basic %s' % b64UserColonPassword
[ "def", "_security_auth_headers", "(", "self", ",", "username", ",", "password", ",", "headers", ")", ":", "userColonPassword", "=", "username", "+", "\":\"", "+", "password", "b64UserColonPassword", "=", "base64", ".", "b64encode", "(", "str_to_bytes", "(", "userColonPassword", ")", ")", ".", "decode", "(", "\"ascii\"", ")", "headers", "[", "'Authorization'", "]", "=", "'Basic %s'", "%", "b64UserColonPassword" ]
Add in the requisite HTTP Authentication Headers :param username: Riak Security Username :type str :param password: Riak Security Password :type str :param headers: Dictionary of headers :type dict
[ "Add", "in", "the", "requisite", "HTTP", "Authentication", "Headers" ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/transports/http/connection.py#L101-L115
train
basho/riak-python-client
riak/table.py
Table.query
def query(self, query, interpolations=None): """ Queries a timeseries table. :param query: The timeseries query. :type query: string :rtype: :class:`TsObject <riak.ts_object.TsObject>` """ return self._client.ts_query(self, query, interpolations)
python
def query(self, query, interpolations=None): """ Queries a timeseries table. :param query: The timeseries query. :type query: string :rtype: :class:`TsObject <riak.ts_object.TsObject>` """ return self._client.ts_query(self, query, interpolations)
[ "def", "query", "(", "self", ",", "query", ",", "interpolations", "=", "None", ")", ":", "return", "self", ".", "_client", ".", "ts_query", "(", "self", ",", "query", ",", "interpolations", ")" ]
Queries a timeseries table. :param query: The timeseries query. :type query: string :rtype: :class:`TsObject <riak.ts_object.TsObject>`
[ "Queries", "a", "timeseries", "table", "." ]
91de13a16607cdf553d1a194e762734e3bec4231
https://github.com/basho/riak-python-client/blob/91de13a16607cdf553d1a194e762734e3bec4231/riak/table.py#L94-L102
train
adamrehn/ue4cli
ue4cli/ConfigurationManager.py
ConfigurationManager.getConfigDirectory
def getConfigDirectory(): """ Determines the platform-specific config directory location for ue4cli """ if platform.system() == 'Windows': return os.path.join(os.environ['APPDATA'], 'ue4cli') else: return os.path.join(os.environ['HOME'], '.config', 'ue4cli')
python
def getConfigDirectory(): """ Determines the platform-specific config directory location for ue4cli """ if platform.system() == 'Windows': return os.path.join(os.environ['APPDATA'], 'ue4cli') else: return os.path.join(os.environ['HOME'], '.config', 'ue4cli')
[ "def", "getConfigDirectory", "(", ")", ":", "if", "platform", ".", "system", "(", ")", "==", "'Windows'", ":", "return", "os", ".", "path", ".", "join", "(", "os", ".", "environ", "[", "'APPDATA'", "]", ",", "'ue4cli'", ")", "else", ":", "return", "os", ".", "path", ".", "join", "(", "os", ".", "environ", "[", "'HOME'", "]", ",", "'.config'", ",", "'ue4cli'", ")" ]
Determines the platform-specific config directory location for ue4cli
[ "Determines", "the", "platform", "-", "specific", "config", "directory", "location", "for", "ue4cli" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/ConfigurationManager.py#L10-L17
train
adamrehn/ue4cli
ue4cli/ConfigurationManager.py
ConfigurationManager.setConfigKey
def setConfigKey(key, value): """ Sets the config data value for the specified dictionary key """ configFile = ConfigurationManager._configFile() return JsonDataManager(configFile).setKey(key, value)
python
def setConfigKey(key, value): """ Sets the config data value for the specified dictionary key """ configFile = ConfigurationManager._configFile() return JsonDataManager(configFile).setKey(key, value)
[ "def", "setConfigKey", "(", "key", ",", "value", ")", ":", "configFile", "=", "ConfigurationManager", ".", "_configFile", "(", ")", "return", "JsonDataManager", "(", "configFile", ")", ".", "setKey", "(", "key", ",", "value", ")" ]
Sets the config data value for the specified dictionary key
[ "Sets", "the", "config", "data", "value", "for", "the", "specified", "dictionary", "key" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/ConfigurationManager.py#L28-L33
train
adamrehn/ue4cli
ue4cli/CachedDataManager.py
CachedDataManager.clearCache
def clearCache(): """ Clears any cached data we have stored about specific engine versions """ if os.path.exists(CachedDataManager._cacheDir()) == True: shutil.rmtree(CachedDataManager._cacheDir())
python
def clearCache(): """ Clears any cached data we have stored about specific engine versions """ if os.path.exists(CachedDataManager._cacheDir()) == True: shutil.rmtree(CachedDataManager._cacheDir())
[ "def", "clearCache", "(", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "CachedDataManager", ".", "_cacheDir", "(", ")", ")", "==", "True", ":", "shutil", ".", "rmtree", "(", "CachedDataManager", ".", "_cacheDir", "(", ")", ")" ]
Clears any cached data we have stored about specific engine versions
[ "Clears", "any", "cached", "data", "we", "have", "stored", "about", "specific", "engine", "versions" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/CachedDataManager.py#L11-L16
train
adamrehn/ue4cli
ue4cli/CachedDataManager.py
CachedDataManager.getCachedDataKey
def getCachedDataKey(engineVersionHash, key): """ Retrieves the cached data value for the specified engine version hash and dictionary key """ cacheFile = CachedDataManager._cacheFileForHash(engineVersionHash) return JsonDataManager(cacheFile).getKey(key)
python
def getCachedDataKey(engineVersionHash, key): """ Retrieves the cached data value for the specified engine version hash and dictionary key """ cacheFile = CachedDataManager._cacheFileForHash(engineVersionHash) return JsonDataManager(cacheFile).getKey(key)
[ "def", "getCachedDataKey", "(", "engineVersionHash", ",", "key", ")", ":", "cacheFile", "=", "CachedDataManager", ".", "_cacheFileForHash", "(", "engineVersionHash", ")", "return", "JsonDataManager", "(", "cacheFile", ")", ".", "getKey", "(", "key", ")" ]
Retrieves the cached data value for the specified engine version hash and dictionary key
[ "Retrieves", "the", "cached", "data", "value", "for", "the", "specified", "engine", "version", "hash", "and", "dictionary", "key" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/CachedDataManager.py#L19-L24
train
adamrehn/ue4cli
ue4cli/CachedDataManager.py
CachedDataManager.setCachedDataKey
def setCachedDataKey(engineVersionHash, key, value): """ Sets the cached data value for the specified engine version hash and dictionary key """ cacheFile = CachedDataManager._cacheFileForHash(engineVersionHash) return JsonDataManager(cacheFile).setKey(key, value)
python
def setCachedDataKey(engineVersionHash, key, value): """ Sets the cached data value for the specified engine version hash and dictionary key """ cacheFile = CachedDataManager._cacheFileForHash(engineVersionHash) return JsonDataManager(cacheFile).setKey(key, value)
[ "def", "setCachedDataKey", "(", "engineVersionHash", ",", "key", ",", "value", ")", ":", "cacheFile", "=", "CachedDataManager", ".", "_cacheFileForHash", "(", "engineVersionHash", ")", "return", "JsonDataManager", "(", "cacheFile", ")", ".", "setKey", "(", "key", ",", "value", ")" ]
Sets the cached data value for the specified engine version hash and dictionary key
[ "Sets", "the", "cached", "data", "value", "for", "the", "specified", "engine", "version", "hash", "and", "dictionary", "key" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/CachedDataManager.py#L27-L32
train
adamrehn/ue4cli
ue4cli/Utility.py
Utility.writeFile
def writeFile(filename, data): """ Writes data to a file """ with open(filename, 'wb') as f: f.write(data.encode('utf-8'))
python
def writeFile(filename, data): """ Writes data to a file """ with open(filename, 'wb') as f: f.write(data.encode('utf-8'))
[ "def", "writeFile", "(", "filename", ",", "data", ")", ":", "with", "open", "(", "filename", ",", "'wb'", ")", "as", "f", ":", "f", ".", "write", "(", "data", ".", "encode", "(", "'utf-8'", ")", ")" ]
Writes data to a file
[ "Writes", "data", "to", "a", "file" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/Utility.py#L34-L39
train
adamrehn/ue4cli
ue4cli/Utility.py
Utility.patchFile
def patchFile(filename, replacements): """ Applies the supplied list of replacements to a file """ patched = Utility.readFile(filename) # Perform each of the replacements in the supplied dictionary for key in replacements: patched = patched.replace(key, replacements[key]) Utility.writeFile(filename, patched)
python
def patchFile(filename, replacements): """ Applies the supplied list of replacements to a file """ patched = Utility.readFile(filename) # Perform each of the replacements in the supplied dictionary for key in replacements: patched = patched.replace(key, replacements[key]) Utility.writeFile(filename, patched)
[ "def", "patchFile", "(", "filename", ",", "replacements", ")", ":", "patched", "=", "Utility", ".", "readFile", "(", "filename", ")", "# Perform each of the replacements in the supplied dictionary", "for", "key", "in", "replacements", ":", "patched", "=", "patched", ".", "replace", "(", "key", ",", "replacements", "[", "key", "]", ")", "Utility", ".", "writeFile", "(", "filename", ",", "patched", ")" ]
Applies the supplied list of replacements to a file
[ "Applies", "the", "supplied", "list", "of", "replacements", "to", "a", "file" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/Utility.py#L42-L52
train
adamrehn/ue4cli
ue4cli/Utility.py
Utility.escapePathForShell
def escapePathForShell(path): """ Escapes a filesystem path for use as a command-line argument """ if platform.system() == 'Windows': return '"{}"'.format(path.replace('"', '""')) else: return shellescape.quote(path)
python
def escapePathForShell(path): """ Escapes a filesystem path for use as a command-line argument """ if platform.system() == 'Windows': return '"{}"'.format(path.replace('"', '""')) else: return shellescape.quote(path)
[ "def", "escapePathForShell", "(", "path", ")", ":", "if", "platform", ".", "system", "(", ")", "==", "'Windows'", ":", "return", "'\"{}\"'", ".", "format", "(", "path", ".", "replace", "(", "'\"'", ",", "'\"\"'", ")", ")", "else", ":", "return", "shellescape", ".", "quote", "(", "path", ")" ]
Escapes a filesystem path for use as a command-line argument
[ "Escapes", "a", "filesystem", "path", "for", "use", "as", "a", "command", "-", "line", "argument" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/Utility.py#L62-L69
train
adamrehn/ue4cli
ue4cli/Utility.py
Utility.join
def join(delim, items, quotes=False): """ Joins the supplied list of strings after removing any empty strings from the list """ transform = lambda s: s if quotes == True: transform = lambda s: s if ' ' not in s else '"{}"'.format(s) stripped = list([transform(i) for i in items if len(i) > 0]) if len(stripped) > 0: return delim.join(stripped) return ''
python
def join(delim, items, quotes=False): """ Joins the supplied list of strings after removing any empty strings from the list """ transform = lambda s: s if quotes == True: transform = lambda s: s if ' ' not in s else '"{}"'.format(s) stripped = list([transform(i) for i in items if len(i) > 0]) if len(stripped) > 0: return delim.join(stripped) return ''
[ "def", "join", "(", "delim", ",", "items", ",", "quotes", "=", "False", ")", ":", "transform", "=", "lambda", "s", ":", "s", "if", "quotes", "==", "True", ":", "transform", "=", "lambda", "s", ":", "s", "if", "' '", "not", "in", "s", "else", "'\"{}\"'", ".", "format", "(", "s", ")", "stripped", "=", "list", "(", "[", "transform", "(", "i", ")", "for", "i", "in", "items", "if", "len", "(", "i", ")", ">", "0", "]", ")", "if", "len", "(", "stripped", ")", ">", "0", ":", "return", "delim", ".", "join", "(", "stripped", ")", "return", "''" ]
Joins the supplied list of strings after removing any empty strings from the list
[ "Joins", "the", "supplied", "list", "of", "strings", "after", "removing", "any", "empty", "strings", "from", "the", "list" ]
f1c34502c96059e36757b7433da7e98760a75a6f
https://github.com/adamrehn/ue4cli/blob/f1c34502c96059e36757b7433da7e98760a75a6f/ue4cli/Utility.py#L72-L83
train