id
int32
0
252k
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
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
241,600
bitlabstudio/django-unshorten
unshorten/rate_limit.py
SimpleRateLimit.get_history
def get_history(self): """Returns the history from cache or DB or a newly created one.""" if hasattr(self, '_history'): return self._history try: self._history = APICallDayHistory.objects.get( user=self.user, creation_date=now().date()) except APIC...
python
def get_history(self): """Returns the history from cache or DB or a newly created one.""" if hasattr(self, '_history'): return self._history try: self._history = APICallDayHistory.objects.get( user=self.user, creation_date=now().date()) except APIC...
[ "def", "get_history", "(", "self", ")", ":", "if", "hasattr", "(", "self", ",", "'_history'", ")", ":", "return", "self", ".", "_history", "try", ":", "self", ".", "_history", "=", "APICallDayHistory", ".", "objects", ".", "get", "(", "user", "=", "sel...
Returns the history from cache or DB or a newly created one.
[ "Returns", "the", "history", "from", "cache", "or", "DB", "or", "a", "newly", "created", "one", "." ]
6d184de908bb9df3aad5ac3fd9732d976afb6953
https://github.com/bitlabstudio/django-unshorten/blob/6d184de908bb9df3aad5ac3fd9732d976afb6953/unshorten/rate_limit.py#L14-L24
241,601
bitlabstudio/django-unshorten
unshorten/rate_limit.py
SimpleRateLimit.is_rate_limit_exceeded
def is_rate_limit_exceeded(self): """Returns ``True`` if the rate limit is exceeded, otherwise False.""" history = self.get_history() if history.amount_api_calls >= settings.UNSHORTEN_DAILY_LIMIT: return True return False
python
def is_rate_limit_exceeded(self): """Returns ``True`` if the rate limit is exceeded, otherwise False.""" history = self.get_history() if history.amount_api_calls >= settings.UNSHORTEN_DAILY_LIMIT: return True return False
[ "def", "is_rate_limit_exceeded", "(", "self", ")", ":", "history", "=", "self", ".", "get_history", "(", ")", "if", "history", ".", "amount_api_calls", ">=", "settings", ".", "UNSHORTEN_DAILY_LIMIT", ":", "return", "True", "return", "False" ]
Returns ``True`` if the rate limit is exceeded, otherwise False.
[ "Returns", "True", "if", "the", "rate", "limit", "is", "exceeded", "otherwise", "False", "." ]
6d184de908bb9df3aad5ac3fd9732d976afb6953
https://github.com/bitlabstudio/django-unshorten/blob/6d184de908bb9df3aad5ac3fd9732d976afb6953/unshorten/rate_limit.py#L26-L31
241,602
bitlabstudio/django-unshorten
unshorten/rate_limit.py
SimpleRateLimit.log_api_call
def log_api_call(self): """Increases the amount of logged API calls for the user by 1.""" history = self.get_history() history.amount_api_calls += 1 self._history = history.save() return history
python
def log_api_call(self): """Increases the amount of logged API calls for the user by 1.""" history = self.get_history() history.amount_api_calls += 1 self._history = history.save() return history
[ "def", "log_api_call", "(", "self", ")", ":", "history", "=", "self", ".", "get_history", "(", ")", "history", ".", "amount_api_calls", "+=", "1", "self", ".", "_history", "=", "history", ".", "save", "(", ")", "return", "history" ]
Increases the amount of logged API calls for the user by 1.
[ "Increases", "the", "amount", "of", "logged", "API", "calls", "for", "the", "user", "by", "1", "." ]
6d184de908bb9df3aad5ac3fd9732d976afb6953
https://github.com/bitlabstudio/django-unshorten/blob/6d184de908bb9df3aad5ac3fd9732d976afb6953/unshorten/rate_limit.py#L33-L38
241,603
jalanb/pysyte
pysyte/lists.py
de_duplicate
def de_duplicate(items): """Remove any duplicate item, preserving order >>> de_duplicate([1, 2, 1, 2]) [1, 2] """ result = [] for item in items: if item not in result: result.append(item) return result
python
def de_duplicate(items): """Remove any duplicate item, preserving order >>> de_duplicate([1, 2, 1, 2]) [1, 2] """ result = [] for item in items: if item not in result: result.append(item) return result
[ "def", "de_duplicate", "(", "items", ")", ":", "result", "=", "[", "]", "for", "item", "in", "items", ":", "if", "item", "not", "in", "result", ":", "result", ".", "append", "(", "item", ")", "return", "result" ]
Remove any duplicate item, preserving order >>> de_duplicate([1, 2, 1, 2]) [1, 2]
[ "Remove", "any", "duplicate", "item", "preserving", "order" ]
4e278101943d1ceb1a6bcaf6ddc72052ecf13114
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/lists.py#L4-L14
241,604
JNRowe/jnrbase
jnrbase/config.py
read_configs
def read_configs(__pkg: str, __name: str = 'config', *, local: bool = True) -> ConfigParser: """Process configuration file stack. We export the time parsing functionality of ``jnrbase`` as custom converters for :class:`configparser.ConfigParser`: =================== =================...
python
def read_configs(__pkg: str, __name: str = 'config', *, local: bool = True) -> ConfigParser: """Process configuration file stack. We export the time parsing functionality of ``jnrbase`` as custom converters for :class:`configparser.ConfigParser`: =================== =================...
[ "def", "read_configs", "(", "__pkg", ":", "str", ",", "__name", ":", "str", "=", "'config'", ",", "*", ",", "local", ":", "bool", "=", "True", ")", "->", "ConfigParser", ":", "configs", "=", "get_configs", "(", "__pkg", ",", "__name", ")", "if", "loc...
Process configuration file stack. We export the time parsing functionality of ``jnrbase`` as custom converters for :class:`configparser.ConfigParser`: =================== =========================================== Method Function =================== ===============================...
[ "Process", "configuration", "file", "stack", "." ]
ae505ef69a9feb739b5f4e62c5a8e6533104d3ea
https://github.com/JNRowe/jnrbase/blob/ae505ef69a9feb739b5f4e62c5a8e6533104d3ea/jnrbase/config.py#L29-L75
241,605
klmitch/tendril
tendril/tcp.py
TCPTendril._start
def _start(self): """ Starts the underlying send and receive threads. """ # Initialize the locks self._recv_lock = coros.Semaphore(0) self._send_lock = coros.Semaphore(0) # Boot the threads self._recv_thread = gevent.spawn(self._recv) self._send_...
python
def _start(self): """ Starts the underlying send and receive threads. """ # Initialize the locks self._recv_lock = coros.Semaphore(0) self._send_lock = coros.Semaphore(0) # Boot the threads self._recv_thread = gevent.spawn(self._recv) self._send_...
[ "def", "_start", "(", "self", ")", ":", "# Initialize the locks", "self", ".", "_recv_lock", "=", "coros", ".", "Semaphore", "(", "0", ")", "self", ".", "_send_lock", "=", "coros", ".", "Semaphore", "(", "0", ")", "# Boot the threads", "self", ".", "_recv_...
Starts the underlying send and receive threads.
[ "Starts", "the", "underlying", "send", "and", "receive", "threads", "." ]
207102c83e88f8f1fa7ba605ef0aab2ae9078b36
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/tcp.py#L76-L92
241,606
klmitch/tendril
tendril/tcp.py
TCPTendril._recv
def _recv(self): """ Implementation of the receive thread. Waits for data to arrive on the socket, then passes the data through the defined receive framer and sends it on to the application. """ # Outer loop: receive some data while True: # Wait unti...
python
def _recv(self): """ Implementation of the receive thread. Waits for data to arrive on the socket, then passes the data through the defined receive framer and sends it on to the application. """ # Outer loop: receive some data while True: # Wait unti...
[ "def", "_recv", "(", "self", ")", ":", "# Outer loop: receive some data", "while", "True", ":", "# Wait until we can go", "self", ".", "_recv_lock", ".", "release", "(", ")", "gevent", ".", "sleep", "(", ")", "# Yield to another thread", "self", ".", "_recv_lock",...
Implementation of the receive thread. Waits for data to arrive on the socket, then passes the data through the defined receive framer and sends it on to the application.
[ "Implementation", "of", "the", "receive", "thread", ".", "Waits", "for", "data", "to", "arrive", "on", "the", "socket", "then", "passes", "the", "data", "through", "the", "defined", "receive", "framer", "and", "sends", "it", "on", "to", "the", "application",...
207102c83e88f8f1fa7ba605ef0aab2ae9078b36
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/tcp.py#L94-L137
241,607
klmitch/tendril
tendril/tcp.py
TCPTendril._thread_error
def _thread_error(self, thread): """ Handles the case that the send or receive thread exit or throw an exception. """ # Avoid double-killing the thread if thread == self._send_thread: self._send_thread = None if thread == self._recv_thread: ...
python
def _thread_error(self, thread): """ Handles the case that the send or receive thread exit or throw an exception. """ # Avoid double-killing the thread if thread == self._send_thread: self._send_thread = None if thread == self._recv_thread: ...
[ "def", "_thread_error", "(", "self", ",", "thread", ")", ":", "# Avoid double-killing the thread", "if", "thread", "==", "self", ".", "_send_thread", ":", "self", ".", "_send_thread", "=", "None", "if", "thread", "==", "self", ".", "_recv_thread", ":", "self",...
Handles the case that the send or receive thread exit or throw an exception.
[ "Handles", "the", "case", "that", "the", "send", "or", "receive", "thread", "exit", "or", "throw", "an", "exception", "." ]
207102c83e88f8f1fa7ba605ef0aab2ae9078b36
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/tcp.py#L165-L191
241,608
klmitch/tendril
tendril/tcp.py
TCPTendril.wrap
def wrap(self, wrapper): """ Allows the underlying socket to be wrapped, as by an SSL connection. :param wrapper: A callable taking, as its first argument, a socket.socket object. The callable must return a valid proxy for the socket.sock...
python
def wrap(self, wrapper): """ Allows the underlying socket to be wrapped, as by an SSL connection. :param wrapper: A callable taking, as its first argument, a socket.socket object. The callable must return a valid proxy for the socket.sock...
[ "def", "wrap", "(", "self", ",", "wrapper", ")", ":", "if", "self", ".", "_recv_thread", "and", "self", ".", "_send_thread", ":", "# Have to suspend the send/recv threads", "self", ".", "_recv_lock", ".", "acquire", "(", ")", "self", ".", "_send_lock", ".", ...
Allows the underlying socket to be wrapped, as by an SSL connection. :param wrapper: A callable taking, as its first argument, a socket.socket object. The callable must return a valid proxy for the socket.socket object, which will...
[ "Allows", "the", "underlying", "socket", "to", "be", "wrapped", "as", "by", "an", "SSL", "connection", "." ]
207102c83e88f8f1fa7ba605ef0aab2ae9078b36
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/tcp.py#L193-L224
241,609
klmitch/tendril
tendril/tcp.py
TCPTendril.close
def close(self): """ Close the connection. Kills the send and receive threads, as well as closing the underlying socket. """ if self._recv_thread: self._recv_thread.kill() self._recv_thread = None if self._send_thread: self._send_thr...
python
def close(self): """ Close the connection. Kills the send and receive threads, as well as closing the underlying socket. """ if self._recv_thread: self._recv_thread.kill() self._recv_thread = None if self._send_thread: self._send_thr...
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_recv_thread", ":", "self", ".", "_recv_thread", ".", "kill", "(", ")", "self", ".", "_recv_thread", "=", "None", "if", "self", ".", "_send_thread", ":", "self", ".", "_send_thread", ".", "kill...
Close the connection. Kills the send and receive threads, as well as closing the underlying socket.
[ "Close", "the", "connection", ".", "Kills", "the", "send", "and", "receive", "threads", "as", "well", "as", "closing", "the", "underlying", "socket", "." ]
207102c83e88f8f1fa7ba605ef0aab2ae9078b36
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/tcp.py#L242-L261
241,610
klmitch/tendril
tendril/tcp.py
TCPTendrilManager.connect
def connect(self, target, acceptor, wrapper=None): """ Initiate a connection from the tendril manager's endpoint. Once the connection is completed, a TCPTendril object will be created and passed to the given acceptor. :param target: The target of the connection attempt. ...
python
def connect(self, target, acceptor, wrapper=None): """ Initiate a connection from the tendril manager's endpoint. Once the connection is completed, a TCPTendril object will be created and passed to the given acceptor. :param target: The target of the connection attempt. ...
[ "def", "connect", "(", "self", ",", "target", ",", "acceptor", ",", "wrapper", "=", "None", ")", ":", "# Call some common sanity-checks", "super", "(", "TCPTendrilManager", ",", "self", ")", ".", "connect", "(", "target", ",", "acceptor", ",", "wrapper", ")"...
Initiate a connection from the tendril manager's endpoint. Once the connection is completed, a TCPTendril object will be created and passed to the given acceptor. :param target: The target of the connection attempt. :param acceptor: A callable which will initialize the state of ...
[ "Initiate", "a", "connection", "from", "the", "tendril", "manager", "s", "endpoint", ".", "Once", "the", "connection", "is", "completed", "a", "TCPTendril", "object", "will", "be", "created", "and", "passed", "to", "the", "given", "acceptor", "." ]
207102c83e88f8f1fa7ba605ef0aab2ae9078b36
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/tcp.py#L276-L330
241,611
klmitch/tendril
tendril/tcp.py
TCPTendrilManager.listener
def listener(self, acceptor, wrapper): """ Listens for new connections to the manager's endpoint. Once a new connection is received, a TCPTendril object is generated for it and it is passed to the acceptor, which must initialize the state of the connection. If no acceptor is gi...
python
def listener(self, acceptor, wrapper): """ Listens for new connections to the manager's endpoint. Once a new connection is received, a TCPTendril object is generated for it and it is passed to the acceptor, which must initialize the state of the connection. If no acceptor is gi...
[ "def", "listener", "(", "self", ",", "acceptor", ",", "wrapper", ")", ":", "# If we have no acceptor, there's nothing for us to do here", "if", "not", "acceptor", ":", "# Not listening on anything", "self", ".", "local_addr", "=", "None", "# Just sleep in a loop", "while"...
Listens for new connections to the manager's endpoint. Once a new connection is received, a TCPTendril object is generated for it and it is passed to the acceptor, which must initialize the state of the connection. If no acceptor is given, no new connections can be initialized. ...
[ "Listens", "for", "new", "connections", "to", "the", "manager", "s", "endpoint", ".", "Once", "a", "new", "connection", "is", "received", "a", "TCPTendril", "object", "is", "generated", "for", "it", "and", "it", "is", "passed", "to", "the", "acceptor", "wh...
207102c83e88f8f1fa7ba605ef0aab2ae9078b36
https://github.com/klmitch/tendril/blob/207102c83e88f8f1fa7ba605ef0aab2ae9078b36/tendril/tcp.py#L332-L404
241,612
noobermin/lspreader
lspreader/dotlsp.py
getdim
def getdim(lsp): ''' Obtain the dimensionality of a .lsp file. This should work for all well formatted .lsp files. Parameters: ----------- lsp : .lsp string Returns a list of dimensions. ''' dims= ['x','y', 'z']; rxs = ['{}-cells *([0-9]+)'.format(x) for x in ['x','y','...
python
def getdim(lsp): ''' Obtain the dimensionality of a .lsp file. This should work for all well formatted .lsp files. Parameters: ----------- lsp : .lsp string Returns a list of dimensions. ''' dims= ['x','y', 'z']; rxs = ['{}-cells *([0-9]+)'.format(x) for x in ['x','y','...
[ "def", "getdim", "(", "lsp", ")", ":", "dims", "=", "[", "'x'", ",", "'y'", ",", "'z'", "]", "rxs", "=", "[", "'{}-cells *([0-9]+)'", ".", "format", "(", "x", ")", "for", "x", "in", "[", "'x'", ",", "'y'", ",", "'z'", "]", "]", "return", "[", ...
Obtain the dimensionality of a .lsp file. This should work for all well formatted .lsp files. Parameters: ----------- lsp : .lsp string Returns a list of dimensions.
[ "Obtain", "the", "dimensionality", "of", "a", ".", "lsp", "file", ".", "This", "should", "work", "for", "all", "well", "formatted", ".", "lsp", "files", "." ]
903b9d6427513b07986ffacf76cbca54e18d8be6
https://github.com/noobermin/lspreader/blob/903b9d6427513b07986ffacf76cbca54e18d8be6/lspreader/dotlsp.py#L26-L41
241,613
noobermin/lspreader
lspreader/dotlsp.py
getpexts
def getpexts(lsp): ''' Get information from pext planes. This might or might not work, use with caution! Parameters: ----------- lsp : .lsp string Returns a list of dicts with information for all pext planes ''' lines=lsp.split('\n'); #unfortunately regex doesn't work ...
python
def getpexts(lsp): ''' Get information from pext planes. This might or might not work, use with caution! Parameters: ----------- lsp : .lsp string Returns a list of dicts with information for all pext planes ''' lines=lsp.split('\n'); #unfortunately regex doesn't work ...
[ "def", "getpexts", "(", "lsp", ")", ":", "lines", "=", "lsp", ".", "split", "(", "'\\n'", ")", "#unfortunately regex doesn't work here", "lns", ",", "planens", "=", "zip", "(", "*", "[", "(", "i", ",", "int", "(", "re", ".", "search", "(", "'^ *extract...
Get information from pext planes. This might or might not work, use with caution! Parameters: ----------- lsp : .lsp string Returns a list of dicts with information for all pext planes
[ "Get", "information", "from", "pext", "planes", ".", "This", "might", "or", "might", "not", "work", "use", "with", "caution!" ]
903b9d6427513b07986ffacf76cbca54e18d8be6
https://github.com/noobermin/lspreader/blob/903b9d6427513b07986ffacf76cbca54e18d8be6/lspreader/dotlsp.py#L43-L92
241,614
shaypal5/comath
comath/array/array.py
percentile
def percentile(sorted_list, percent, key=lambda x: x): """Find the percentile of a sorted list of values. Arguments --------- sorted_list : list A sorted (ascending) list of values. percent : float A float value from 0.0 to 1.0. key : function, optional An optional funct...
python
def percentile(sorted_list, percent, key=lambda x: x): """Find the percentile of a sorted list of values. Arguments --------- sorted_list : list A sorted (ascending) list of values. percent : float A float value from 0.0 to 1.0. key : function, optional An optional funct...
[ "def", "percentile", "(", "sorted_list", ",", "percent", ",", "key", "=", "lambda", "x", ":", "x", ")", ":", "if", "not", "sorted_list", ":", "return", "None", "if", "percent", "==", "1", ":", "return", "float", "(", "sorted_list", "[", "-", "1", "]"...
Find the percentile of a sorted list of values. Arguments --------- sorted_list : list A sorted (ascending) list of values. percent : float A float value from 0.0 to 1.0. key : function, optional An optional function to compute a value from each element of N. Returns ...
[ "Find", "the", "percentile", "of", "a", "sorted", "list", "of", "values", "." ]
1333e3b96242a5bad9d3e699ffd58a1597fdc89f
https://github.com/shaypal5/comath/blob/1333e3b96242a5bad9d3e699ffd58a1597fdc89f/comath/array/array.py#L24-L68
241,615
Apitax/Apitax
apitax/api/controllers/api_controller.py
get_driver_api_catalog
def get_driver_api_catalog(driver): # noqa: E501 """Retrieve the api catalog Retrieve the api catalog # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :rtype: Response """ response = errorIfUnauthorized(role='developer') if response: ...
python
def get_driver_api_catalog(driver): # noqa: E501 """Retrieve the api catalog Retrieve the api catalog # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :rtype: Response """ response = errorIfUnauthorized(role='developer') if response: ...
[ "def", "get_driver_api_catalog", "(", "driver", ")", ":", "# noqa: E501", "response", "=", "errorIfUnauthorized", "(", "role", "=", "'developer'", ")", "if", "response", ":", "return", "response", "else", ":", "response", "=", "ApitaxResponse", "(", ")", "driver...
Retrieve the api catalog Retrieve the api catalog # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :rtype: Response
[ "Retrieve", "the", "api", "catalog" ]
3883e45f17e01eba4edac9d1bba42f0e7a748682
https://github.com/Apitax/Apitax/blob/3883e45f17e01eba4edac9d1bba42f0e7a748682/apitax/api/controllers/api_controller.py#L17-L36
241,616
Apitax/Apitax
apitax/api/controllers/api_controller.py
get_driver_api_status
def get_driver_api_status(driver): # noqa: E501 """Retrieve the status of an api backing a driver Retrieve the status of an api backing a driver # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :rtype: Response """ response = errorIfUnauthorized...
python
def get_driver_api_status(driver): # noqa: E501 """Retrieve the status of an api backing a driver Retrieve the status of an api backing a driver # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :rtype: Response """ response = errorIfUnauthorized...
[ "def", "get_driver_api_status", "(", "driver", ")", ":", "# noqa: E501", "response", "=", "errorIfUnauthorized", "(", "role", "=", "'developer'", ")", "if", "response", ":", "return", "response", "else", ":", "response", "=", "ApitaxResponse", "(", ")", "driver"...
Retrieve the status of an api backing a driver Retrieve the status of an api backing a driver # noqa: E501 :param driver: The driver to use for the request. ie. github :type driver: str :rtype: Response
[ "Retrieve", "the", "status", "of", "an", "api", "backing", "a", "driver" ]
3883e45f17e01eba4edac9d1bba42f0e7a748682
https://github.com/Apitax/Apitax/blob/3883e45f17e01eba4edac9d1bba42f0e7a748682/apitax/api/controllers/api_controller.py#L40-L75
241,617
kejbaly2/idid
idid/logg.py
Logg._parse_engine
def _parse_engine(engine): """ Parse the engine uri to determine where to store loggs """ engine = (engine or '').strip() backend, path = URI_RE.match(engine).groups() if backend not in SUPPORTED_BACKENDS: raise NotImplementedError( "Logg supports only {0} fo...
python
def _parse_engine(engine): """ Parse the engine uri to determine where to store loggs """ engine = (engine or '').strip() backend, path = URI_RE.match(engine).groups() if backend not in SUPPORTED_BACKENDS: raise NotImplementedError( "Logg supports only {0} fo...
[ "def", "_parse_engine", "(", "engine", ")", ":", "engine", "=", "(", "engine", "or", "''", ")", ".", "strip", "(", ")", "backend", ",", "path", "=", "URI_RE", ".", "match", "(", "engine", ")", ".", "groups", "(", ")", "if", "backend", "not", "in", ...
Parse the engine uri to determine where to store loggs
[ "Parse", "the", "engine", "uri", "to", "determine", "where", "to", "store", "loggs" ]
0f19e9ca9c8fa4a81e95c490dfbbc1b452c7451c
https://github.com/kejbaly2/idid/blob/0f19e9ca9c8fa4a81e95c490dfbbc1b452c7451c/idid/logg.py#L199-L208
241,618
kejbaly2/idid
idid/logg.py
GitLogg._init_repo
def _init_repo(self): """ create and initialize a new Git Repo """ log.debug("initializing new Git Repo: {0}".format(self._engine_path)) if os.path.exists(self._engine_path): log.error("Path already exists! Aborting!") raise RuntimeError else: # create...
python
def _init_repo(self): """ create and initialize a new Git Repo """ log.debug("initializing new Git Repo: {0}".format(self._engine_path)) if os.path.exists(self._engine_path): log.error("Path already exists! Aborting!") raise RuntimeError else: # create...
[ "def", "_init_repo", "(", "self", ")", ":", "log", ".", "debug", "(", "\"initializing new Git Repo: {0}\"", ".", "format", "(", "self", ".", "_engine_path", ")", ")", "if", "os", ".", "path", ".", "exists", "(", "self", ".", "_engine_path", ")", ":", "lo...
create and initialize a new Git Repo
[ "create", "and", "initialize", "a", "new", "Git", "Repo" ]
0f19e9ca9c8fa4a81e95c490dfbbc1b452c7451c
https://github.com/kejbaly2/idid/blob/0f19e9ca9c8fa4a81e95c490dfbbc1b452c7451c/idid/logg.py#L366-L379
241,619
kejbaly2/idid
idid/logg.py
GitLogg._load_repo
def _load_repo(self): """ Load git repo using GitPython """ if self._logg_repo: return self._logg_repo try: _logg_repo = git.Repo(self._engine_path) log.debug('Loaded git repo [{0}]'.format(self._engine_path)) except Exception: # FIXME: sh...
python
def _load_repo(self): """ Load git repo using GitPython """ if self._logg_repo: return self._logg_repo try: _logg_repo = git.Repo(self._engine_path) log.debug('Loaded git repo [{0}]'.format(self._engine_path)) except Exception: # FIXME: sh...
[ "def", "_load_repo", "(", "self", ")", ":", "if", "self", ".", "_logg_repo", ":", "return", "self", ".", "_logg_repo", "try", ":", "_logg_repo", "=", "git", ".", "Repo", "(", "self", ".", "_engine_path", ")", "log", ".", "debug", "(", "'Loaded git repo [...
Load git repo using GitPython
[ "Load", "git", "repo", "using", "GitPython" ]
0f19e9ca9c8fa4a81e95c490dfbbc1b452c7451c
https://github.com/kejbaly2/idid/blob/0f19e9ca9c8fa4a81e95c490dfbbc1b452c7451c/idid/logg.py#L381-L393
241,620
diffeo/yakonfig
yakonfig/cmd.py
ArgParseCmd.add_arguments
def add_arguments(self, parser): '''Add generic command-line arguments to a top-level argparse parser. After running this, the results from ``argparse.parse_args()`` can be passed to :meth:`main`. ''' commands = set(name[3:] for name in dir(self) if name.startswith('do_')) ...
python
def add_arguments(self, parser): '''Add generic command-line arguments to a top-level argparse parser. After running this, the results from ``argparse.parse_args()`` can be passed to :meth:`main`. ''' commands = set(name[3:] for name in dir(self) if name.startswith('do_')) ...
[ "def", "add_arguments", "(", "self", ",", "parser", ")", ":", "commands", "=", "set", "(", "name", "[", "3", ":", "]", "for", "name", "in", "dir", "(", "self", ")", "if", "name", ".", "startswith", "(", "'do_'", ")", ")", "parser", ".", "add_argume...
Add generic command-line arguments to a top-level argparse parser. After running this, the results from ``argparse.parse_args()`` can be passed to :meth:`main`.
[ "Add", "generic", "command", "-", "line", "arguments", "to", "a", "top", "-", "level", "argparse", "parser", "." ]
412e195da29b4f4fc7b72967c192714a6f5eaeb5
https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/cmd.py#L84-L95
241,621
diffeo/yakonfig
yakonfig/cmd.py
ArgParseCmd.main
def main(self, args): '''Run a single command, or else the main shell loop. `args` should be the :class:`argparse.Namespace` object after being set up via :meth:`add_arguments`. ''' if args.action: self.runcmd(args.action, args.arguments) else: s...
python
def main(self, args): '''Run a single command, or else the main shell loop. `args` should be the :class:`argparse.Namespace` object after being set up via :meth:`add_arguments`. ''' if args.action: self.runcmd(args.action, args.arguments) else: s...
[ "def", "main", "(", "self", ",", "args", ")", ":", "if", "args", ".", "action", ":", "self", ".", "runcmd", "(", "args", ".", "action", ",", "args", ".", "arguments", ")", "else", ":", "self", ".", "cmdloop", "(", ")" ]
Run a single command, or else the main shell loop. `args` should be the :class:`argparse.Namespace` object after being set up via :meth:`add_arguments`.
[ "Run", "a", "single", "command", "or", "else", "the", "main", "shell", "loop", "." ]
412e195da29b4f4fc7b72967c192714a6f5eaeb5
https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/cmd.py#L97-L107
241,622
diffeo/yakonfig
yakonfig/cmd.py
ArgParseCmd.runcmd
def runcmd(self, cmd, args): '''Run a single command from pre-parsed arguments. This is intended to be run from :meth:`main` or somewhere else "at the top level" of the program. It may raise :exc:`exceptions.SystemExit` if an argument such as ``--help`` that normally causes exe...
python
def runcmd(self, cmd, args): '''Run a single command from pre-parsed arguments. This is intended to be run from :meth:`main` or somewhere else "at the top level" of the program. It may raise :exc:`exceptions.SystemExit` if an argument such as ``--help`` that normally causes exe...
[ "def", "runcmd", "(", "self", ",", "cmd", ",", "args", ")", ":", "dof", "=", "getattr", "(", "self", ",", "'do_'", "+", "cmd", ",", "None", ")", "if", "dof", "is", "None", ":", "return", "self", ".", "default", "(", "' '", ".", "join", "(", "["...
Run a single command from pre-parsed arguments. This is intended to be run from :meth:`main` or somewhere else "at the top level" of the program. It may raise :exc:`exceptions.SystemExit` if an argument such as ``--help`` that normally causes execution to stop is encountered.
[ "Run", "a", "single", "command", "from", "pre", "-", "parsed", "arguments", "." ]
412e195da29b4f4fc7b72967c192714a6f5eaeb5
https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/cmd.py#L109-L130
241,623
diffeo/yakonfig
yakonfig/cmd.py
ArgParseCmd.do_help
def do_help(self, args): '''print help on a command''' if args.command: f = getattr(self, 'help_' + args.command, None) if f: f() return f = getattr(self, 'do_' + args.command, None) if not f: msg = self.noh...
python
def do_help(self, args): '''print help on a command''' if args.command: f = getattr(self, 'help_' + args.command, None) if f: f() return f = getattr(self, 'do_' + args.command, None) if not f: msg = self.noh...
[ "def", "do_help", "(", "self", ",", "args", ")", ":", "if", "args", ".", "command", ":", "f", "=", "getattr", "(", "self", ",", "'help_'", "+", "args", ".", "command", ",", "None", ")", "if", "f", ":", "f", "(", ")", "return", "f", "=", "getatt...
print help on a command
[ "print", "help", "on", "a", "command" ]
412e195da29b4f4fc7b72967c192714a6f5eaeb5
https://github.com/diffeo/yakonfig/blob/412e195da29b4f4fc7b72967c192714a6f5eaeb5/yakonfig/cmd.py#L156-L183
241,624
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/utils.py
load_kb_mappings_file
def load_kb_mappings_file(kbname, kbfile, separator): """Add KB values from file to given KB returning rows added.""" num_added = 0 with open(kbfile) as kb_fd: for line in kb_fd: if not line.strip(): continue try: key, value = line.split(separa...
python
def load_kb_mappings_file(kbname, kbfile, separator): """Add KB values from file to given KB returning rows added.""" num_added = 0 with open(kbfile) as kb_fd: for line in kb_fd: if not line.strip(): continue try: key, value = line.split(separa...
[ "def", "load_kb_mappings_file", "(", "kbname", ",", "kbfile", ",", "separator", ")", ":", "num_added", "=", "0", "with", "open", "(", "kbfile", ")", "as", "kb_fd", ":", "for", "line", "in", "kb_fd", ":", "if", "not", "line", ".", "strip", "(", ")", "...
Add KB values from file to given KB returning rows added.
[ "Add", "KB", "values", "from", "file", "to", "given", "KB", "returning", "rows", "added", "." ]
b31722dc14243ca8f626f8b3bce9718d0119de55
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/utils.py#L27-L42
241,625
alantygel/ckanext-semantictags
ckanext/semantictags/db.py
SemanticTag.by_id
def by_id(cls, semantictag_id, autoflush=True): '''Return the semantic tag with the given id, or None. :param semantictag_id: the id of the semantic tag to return :type semantictag_id: string :returns: the semantic tag with the given id, or None if there is no tag with that id :rtype: ckan.model.semantic...
python
def by_id(cls, semantictag_id, autoflush=True): '''Return the semantic tag with the given id, or None. :param semantictag_id: the id of the semantic tag to return :type semantictag_id: string :returns: the semantic tag with the given id, or None if there is no tag with that id :rtype: ckan.model.semantic...
[ "def", "by_id", "(", "cls", ",", "semantictag_id", ",", "autoflush", "=", "True", ")", ":", "query", "=", "meta", ".", "Session", ".", "query", "(", "SemanticTag", ")", ".", "filter", "(", "SemanticTag", ".", "id", "==", "semantictag_id", ")", "query", ...
Return the semantic tag with the given id, or None. :param semantictag_id: the id of the semantic tag to return :type semantictag_id: string :returns: the semantic tag with the given id, or None if there is no tag with that id :rtype: ckan.model.semantictag.SemanticTag # TODO check this
[ "Return", "the", "semantic", "tag", "with", "the", "given", "id", "or", "None", "." ]
10bb31d29f34b2b5a6feae693961842f93007ce1
https://github.com/alantygel/ckanext-semantictags/blob/10bb31d29f34b2b5a6feae693961842f93007ce1/ckanext/semantictags/db.py#L60-L74
241,626
alantygel/ckanext-semantictags
ckanext/semantictags/db.py
SemanticTag.by_URI
def by_URI(cls, URI, label=None, autoflush=True): '''Return the semantic ag with the given URI, or None. :param URI: the URI of the semantic tag to return :type URI: string (URI format) :param label: URI's label (optional, default: None) :type label: string :returns: the semantic tag object with the given...
python
def by_URI(cls, URI, label=None, autoflush=True): '''Return the semantic ag with the given URI, or None. :param URI: the URI of the semantic tag to return :type URI: string (URI format) :param label: URI's label (optional, default: None) :type label: string :returns: the semantic tag object with the given...
[ "def", "by_URI", "(", "cls", ",", "URI", ",", "label", "=", "None", ",", "autoflush", "=", "True", ")", ":", "if", "label", ":", "query", "=", "meta", ".", "Session", ".", "query", "(", "SemanticTag", ")", ".", "filter", "(", "SemanticTag", ".", "l...
Return the semantic ag with the given URI, or None. :param URI: the URI of the semantic tag to return :type URI: string (URI format) :param label: URI's label (optional, default: None) :type label: string :returns: the semantic tag object with the given id or URI, or None if there is no tag with that id ...
[ "Return", "the", "semantic", "ag", "with", "the", "given", "URI", "or", "None", "." ]
10bb31d29f34b2b5a6feae693961842f93007ce1
https://github.com/alantygel/ckanext-semantictags/blob/10bb31d29f34b2b5a6feae693961842f93007ce1/ckanext/semantictags/db.py#L77-L96
241,627
alantygel/ckanext-semantictags
ckanext/semantictags/db.py
SemanticTag.get
def get(cls, tag_id_or_URI, label=None): '''Return the tag with the given id or URI, or None. :param tag_id_or_name: the id or name of the tag to return :type tag_id_or_name: string :returns: the tag object with the given id or name, or None if there is no tag with that id or name :rtype: ckan.model.tag....
python
def get(cls, tag_id_or_URI, label=None): '''Return the tag with the given id or URI, or None. :param tag_id_or_name: the id or name of the tag to return :type tag_id_or_name: string :returns: the tag object with the given id or name, or None if there is no tag with that id or name :rtype: ckan.model.tag....
[ "def", "get", "(", "cls", ",", "tag_id_or_URI", ",", "label", "=", "None", ")", ":", "# First try to get the tag by ID.", "semantictag", "=", "SemanticTag", ".", "by_id", "(", "tag_id_or_URI", ")", "if", "semantictag", ":", "return", "semantictag", "else", ":", ...
Return the tag with the given id or URI, or None. :param tag_id_or_name: the id or name of the tag to return :type tag_id_or_name: string :returns: the tag object with the given id or name, or None if there is no tag with that id or name :rtype: ckan.model.tag.Tag
[ "Return", "the", "tag", "with", "the", "given", "id", "or", "URI", "or", "None", "." ]
10bb31d29f34b2b5a6feae693961842f93007ce1
https://github.com/alantygel/ckanext-semantictags/blob/10bb31d29f34b2b5a6feae693961842f93007ce1/ckanext/semantictags/db.py#L99-L117
241,628
alantygel/ckanext-semantictags
ckanext/semantictags/db.py
SemanticTag.search_by_URI
def search_by_URI(cls, search_term): '''Return all tags whose URI or label contain a given string. :param search_term: the string to search for in the URI or label names :type search_term: string :returns: a list of semantictags that match the search term :rtype: list of ckan.model.semantictag.SemanticTag o...
python
def search_by_URI(cls, search_term): '''Return all tags whose URI or label contain a given string. :param search_term: the string to search for in the URI or label names :type search_term: string :returns: a list of semantictags that match the search term :rtype: list of ckan.model.semantictag.SemanticTag o...
[ "def", "search_by_URI", "(", "cls", ",", "search_term", ")", ":", "#TODO include label search", "query", "=", "meta", ".", "Session", ".", "query", "(", "SemanticTag", ")", "search_term", "=", "search_term", ".", "strip", "(", ")", ".", "lower", "(", ")", ...
Return all tags whose URI or label contain a given string. :param search_term: the string to search for in the URI or label names :type search_term: string :returns: a list of semantictags that match the search term :rtype: list of ckan.model.semantictag.SemanticTag objects
[ "Return", "all", "tags", "whose", "URI", "or", "label", "contain", "a", "given", "string", "." ]
10bb31d29f34b2b5a6feae693961842f93007ce1
https://github.com/alantygel/ckanext-semantictags/blob/10bb31d29f34b2b5a6feae693961842f93007ce1/ckanext/semantictags/db.py#L121-L136
241,629
alantygel/ckanext-semantictags
ckanext/semantictags/db.py
SemanticTag.all
def all(cls): '''Return all tags that are currently applied to any dataset. :returns: a list of all tags that are currently applied to any dataset :rtype: list of ckan.model.tag.Tag objects ''' # if vocab_id_or_name: # vocab = vocabulary.Vocabulary.get(vocab_id_or_name) # if vocab is None: # # The use...
python
def all(cls): '''Return all tags that are currently applied to any dataset. :returns: a list of all tags that are currently applied to any dataset :rtype: list of ckan.model.tag.Tag objects ''' # if vocab_id_or_name: # vocab = vocabulary.Vocabulary.get(vocab_id_or_name) # if vocab is None: # # The use...
[ "def", "all", "(", "cls", ")", ":", "#\t\tif vocab_id_or_name:", "#\t\t\tvocab = vocabulary.Vocabulary.get(vocab_id_or_name)", "#\t\t\tif vocab is None:", "#\t\t\t\t# The user specified an invalid vocab.", "#\t\t\t\traise ckan.logic.NotFound(\"could not find vocabulary '%s'\"", "#\t\t\t\t\t\t%...
Return all tags that are currently applied to any dataset. :returns: a list of all tags that are currently applied to any dataset :rtype: list of ckan.model.tag.Tag objects
[ "Return", "all", "tags", "that", "are", "currently", "applied", "to", "any", "dataset", "." ]
10bb31d29f34b2b5a6feae693961842f93007ce1
https://github.com/alantygel/ckanext-semantictags/blob/10bb31d29f34b2b5a6feae693961842f93007ce1/ckanext/semantictags/db.py#L150-L168
241,630
alantygel/ckanext-semantictags
ckanext/semantictags/db.py
SemanticTag.tags
def tags(self): '''Return a list of all tags that have this semantic tag, sorted by name. :rtype: list of ckan.model.tag.Tag objects ''' q = meta.Session.query(_tag.Tag) q = q.join(TagSemanticTag) q = q.filter_by(tag_id=self.id) # q = q.filter_by(state='active') q = q.order_by(_tag.Tag.name) tags = q...
python
def tags(self): '''Return a list of all tags that have this semantic tag, sorted by name. :rtype: list of ckan.model.tag.Tag objects ''' q = meta.Session.query(_tag.Tag) q = q.join(TagSemanticTag) q = q.filter_by(tag_id=self.id) # q = q.filter_by(state='active') q = q.order_by(_tag.Tag.name) tags = q...
[ "def", "tags", "(", "self", ")", ":", "q", "=", "meta", ".", "Session", ".", "query", "(", "_tag", ".", "Tag", ")", "q", "=", "q", ".", "join", "(", "TagSemanticTag", ")", "q", "=", "q", ".", "filter_by", "(", "tag_id", "=", "self", ".", "id", ...
Return a list of all tags that have this semantic tag, sorted by name. :rtype: list of ckan.model.tag.Tag objects
[ "Return", "a", "list", "of", "all", "tags", "that", "have", "this", "semantic", "tag", "sorted", "by", "name", "." ]
10bb31d29f34b2b5a6feae693961842f93007ce1
https://github.com/alantygel/ckanext-semantictags/blob/10bb31d29f34b2b5a6feae693961842f93007ce1/ckanext/semantictags/db.py#L171-L183
241,631
alantygel/ckanext-semantictags
ckanext/semantictags/db.py
Predicate.by_id
def by_id(cls, predicate_id, autoflush=True): '''Return the predicate with the given id, or None. :param predicate_id: the id of the predicate to return :type predicate_id: string :returns: the predicate with the given id, or None if there is no predicate with that id :rtype: ckan.model.semantictag.Predi...
python
def by_id(cls, predicate_id, autoflush=True): '''Return the predicate with the given id, or None. :param predicate_id: the id of the predicate to return :type predicate_id: string :returns: the predicate with the given id, or None if there is no predicate with that id :rtype: ckan.model.semantictag.Predi...
[ "def", "by_id", "(", "cls", ",", "predicate_id", ",", "autoflush", "=", "True", ")", ":", "query", "=", "meta", ".", "Session", ".", "query", "(", "Predicate", ")", ".", "filter", "(", "Predicate", ".", "id", "==", "predicate_id", ")", "query", "=", ...
Return the predicate with the given id, or None. :param predicate_id: the id of the predicate to return :type predicate_id: string :returns: the predicate with the given id, or None if there is no predicate with that id :rtype: ckan.model.semantictag.Predicate
[ "Return", "the", "predicate", "with", "the", "given", "id", "or", "None", "." ]
10bb31d29f34b2b5a6feae693961842f93007ce1
https://github.com/alantygel/ckanext-semantictags/blob/10bb31d29f34b2b5a6feae693961842f93007ce1/ckanext/semantictags/db.py#L204-L217
241,632
alantygel/ckanext-semantictags
ckanext/semantictags/db.py
Predicate.list_unique
def list_unique(cls): '''Return all unique namespaces :returns: a list of all predicates :rtype: list of ckan.model.semantictag.Predicate objects ''' query = meta.Session.query(Predicate).distinct(Predicate.namespace) return query.all()
python
def list_unique(cls): '''Return all unique namespaces :returns: a list of all predicates :rtype: list of ckan.model.semantictag.Predicate objects ''' query = meta.Session.query(Predicate).distinct(Predicate.namespace) return query.all()
[ "def", "list_unique", "(", "cls", ")", ":", "query", "=", "meta", ".", "Session", ".", "query", "(", "Predicate", ")", ".", "distinct", "(", "Predicate", ".", "namespace", ")", "return", "query", ".", "all", "(", ")" ]
Return all unique namespaces :returns: a list of all predicates :rtype: list of ckan.model.semantictag.Predicate objects
[ "Return", "all", "unique", "namespaces" ]
10bb31d29f34b2b5a6feae693961842f93007ce1
https://github.com/alantygel/ckanext-semantictags/blob/10bb31d29f34b2b5a6feae693961842f93007ce1/ckanext/semantictags/db.py#L252-L260
241,633
alantygel/ckanext-semantictags
ckanext/semantictags/db.py
TagSemanticTag.by_name
def by_name(self, tag_name, semantictag_URI, autoflush=True): '''Return the TagSemanticTag for the given tag name and semantic tag URI, or None. :param tag_name: the name of the tag to look for :type tag_name: string :param tag_URI: the name of the tag to look for :type tag_URI: string :returns: the Ta...
python
def by_name(self, tag_name, semantictag_URI, autoflush=True): '''Return the TagSemanticTag for the given tag name and semantic tag URI, or None. :param tag_name: the name of the tag to look for :type tag_name: string :param tag_URI: the name of the tag to look for :type tag_URI: string :returns: the Ta...
[ "def", "by_name", "(", "self", ",", "tag_name", ",", "semantictag_URI", ",", "autoflush", "=", "True", ")", ":", "query", "=", "(", "meta", ".", "Session", ".", "query", "(", "TagSemanticTag", ")", ".", "filter", "(", "_tag", ".", "Tag", ".", "name", ...
Return the TagSemanticTag for the given tag name and semantic tag URI, or None. :param tag_name: the name of the tag to look for :type tag_name: string :param tag_URI: the name of the tag to look for :type tag_URI: string :returns: the TagSemanticTag for the given tag name and semantic tag URI, or None i...
[ "Return", "the", "TagSemanticTag", "for", "the", "given", "tag", "name", "and", "semantic", "tag", "URI", "or", "None", "." ]
10bb31d29f34b2b5a6feae693961842f93007ce1
https://github.com/alantygel/ckanext-semantictags/blob/10bb31d29f34b2b5a6feae693961842f93007ce1/ckanext/semantictags/db.py#L305-L324
241,634
cabalgata/cabalgata-silla-de-montar
cabalgata/silla/util/disk.py
temp_directory
def temp_directory(*args, **kwargs): """ Context manager returns a path created by mkdtemp and cleans it up afterwards. """ path = tempfile.mkdtemp(*args, **kwargs) try: yield path finally: shutil.rmtree(path)
python
def temp_directory(*args, **kwargs): """ Context manager returns a path created by mkdtemp and cleans it up afterwards. """ path = tempfile.mkdtemp(*args, **kwargs) try: yield path finally: shutil.rmtree(path)
[ "def", "temp_directory", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "path", "=", "tempfile", ".", "mkdtemp", "(", "*", "args", ",", "*", "*", "kwargs", ")", "try", ":", "yield", "path", "finally", ":", "shutil", ".", "rmtree", "(", "path"...
Context manager returns a path created by mkdtemp and cleans it up afterwards.
[ "Context", "manager", "returns", "a", "path", "created", "by", "mkdtemp", "and", "cleans", "it", "up", "afterwards", "." ]
6f1de56f207e55d788d56636f623c0e3ce1aa750
https://github.com/cabalgata/cabalgata-silla-de-montar/blob/6f1de56f207e55d788d56636f623c0e3ce1aa750/cabalgata/silla/util/disk.py#L27-L36
241,635
mjalas/messaging-client
messaging_client/option_parser.py
DefaultOptionParser.parse
def parse(self): """Parse command line arguments and options. Returns: Dictionary containing all given command line arguments and options. """ (options, args) = self.parser.parse_args() self._set_attributes(args, options) return self._create_dictionary()
python
def parse(self): """Parse command line arguments and options. Returns: Dictionary containing all given command line arguments and options. """ (options, args) = self.parser.parse_args() self._set_attributes(args, options) return self._create_dictionary()
[ "def", "parse", "(", "self", ")", ":", "(", "options", ",", "args", ")", "=", "self", ".", "parser", ".", "parse_args", "(", ")", "self", ".", "_set_attributes", "(", "args", ",", "options", ")", "return", "self", ".", "_create_dictionary", "(", ")" ]
Parse command line arguments and options. Returns: Dictionary containing all given command line arguments and options.
[ "Parse", "command", "line", "arguments", "and", "options", "." ]
b72ad622d9c94a879fe1085f0dbb52349892cd15
https://github.com/mjalas/messaging-client/blob/b72ad622d9c94a879fe1085f0dbb52349892cd15/messaging_client/option_parser.py#L58-L66
241,636
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
WinDir.prt_detail
def prt_detail(self): """Nicely print stats information. """ screen = [ "Detail info of %s: " % self.abspath, "total size = %s" % string_SizeInBytes(self.size_total), "number of sub folders = %s" % self.num_folder_total, "number of total files = %s...
python
def prt_detail(self): """Nicely print stats information. """ screen = [ "Detail info of %s: " % self.abspath, "total size = %s" % string_SizeInBytes(self.size_total), "number of sub folders = %s" % self.num_folder_total, "number of total files = %s...
[ "def", "prt_detail", "(", "self", ")", ":", "screen", "=", "[", "\"Detail info of %s: \"", "%", "self", ".", "abspath", ",", "\"total size = %s\"", "%", "string_SizeInBytes", "(", "self", ".", "size_total", ")", ",", "\"number of sub folders = %s\"", "%", "self", ...
Nicely print stats information.
[ "Nicely", "print", "stats", "information", "." ]
689a60da51cd88680ddbe26e28dbe81e6b01d275
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L411-L423
241,637
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.add
def add(self, abspath_or_winfile, enable_verbose=True): """Add absolute path or WinFile to FileCollection. """ if isinstance(abspath_or_winfile, str): # abspath if abspath_or_winfile in self.files: if enable_verbose: print("'%s' already in this col...
python
def add(self, abspath_or_winfile, enable_verbose=True): """Add absolute path or WinFile to FileCollection. """ if isinstance(abspath_or_winfile, str): # abspath if abspath_or_winfile in self.files: if enable_verbose: print("'%s' already in this col...
[ "def", "add", "(", "self", ",", "abspath_or_winfile", ",", "enable_verbose", "=", "True", ")", ":", "if", "isinstance", "(", "abspath_or_winfile", ",", "str", ")", ":", "# abspath", "if", "abspath_or_winfile", "in", "self", ".", "files", ":", "if", "enable_v...
Add absolute path or WinFile to FileCollection.
[ "Add", "absolute", "path", "or", "WinFile", "to", "FileCollection", "." ]
689a60da51cd88680ddbe26e28dbe81e6b01d275
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L505-L523
241,638
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.remove
def remove(self, abspath_or_winfile, enable_verbose=True): """Remove absolute path or WinFile from FileCollection. """ if isinstance(abspath_or_winfile, str): # abspath try: del self.files[abspath_or_winfile] except KeyError: if enable_verb...
python
def remove(self, abspath_or_winfile, enable_verbose=True): """Remove absolute path or WinFile from FileCollection. """ if isinstance(abspath_or_winfile, str): # abspath try: del self.files[abspath_or_winfile] except KeyError: if enable_verb...
[ "def", "remove", "(", "self", ",", "abspath_or_winfile", ",", "enable_verbose", "=", "True", ")", ":", "if", "isinstance", "(", "abspath_or_winfile", ",", "str", ")", ":", "# abspath", "try", ":", "del", "self", ".", "files", "[", "abspath_or_winfile", "]", ...
Remove absolute path or WinFile from FileCollection.
[ "Remove", "absolute", "path", "or", "WinFile", "from", "FileCollection", "." ]
689a60da51cd88680ddbe26e28dbe81e6b01d275
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L525-L543
241,639
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.iterfiles
def iterfiles(self): """Yield all WinFile object. """ try: for path in self.order: yield self.files[path] except: for winfile in self.files.values(): yield winfile
python
def iterfiles(self): """Yield all WinFile object. """ try: for path in self.order: yield self.files[path] except: for winfile in self.files.values(): yield winfile
[ "def", "iterfiles", "(", "self", ")", ":", "try", ":", "for", "path", "in", "self", ".", "order", ":", "yield", "self", ".", "files", "[", "path", "]", "except", ":", "for", "winfile", "in", "self", ".", "files", ".", "values", "(", ")", ":", "yi...
Yield all WinFile object.
[ "Yield", "all", "WinFile", "object", "." ]
689a60da51cd88680ddbe26e28dbe81e6b01d275
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L551-L559
241,640
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.iterpaths
def iterpaths(self): """Yield all WinFile's absolute path. """ try: for path in self.order: yield path except: for path in self.files: yield path
python
def iterpaths(self): """Yield all WinFile's absolute path. """ try: for path in self.order: yield path except: for path in self.files: yield path
[ "def", "iterpaths", "(", "self", ")", ":", "try", ":", "for", "path", "in", "self", ".", "order", ":", "yield", "path", "except", ":", "for", "path", "in", "self", ".", "files", ":", "yield", "path" ]
Yield all WinFile's absolute path.
[ "Yield", "all", "WinFile", "s", "absolute", "path", "." ]
689a60da51cd88680ddbe26e28dbe81e6b01d275
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L561-L569
241,641
MacHu-GWU/angora-project
angora/filesystem/filesystem.py
FileCollection.show_patterned_file
def show_patterned_file(dir_path, pattern=list(), filename_only=True): """Print all file that file name contains ``pattern``. """ pattern = [i.lower() for i in pattern] if filename_only: def filter(winfile): for p in pattern: if p in winfil...
python
def show_patterned_file(dir_path, pattern=list(), filename_only=True): """Print all file that file name contains ``pattern``. """ pattern = [i.lower() for i in pattern] if filename_only: def filter(winfile): for p in pattern: if p in winfil...
[ "def", "show_patterned_file", "(", "dir_path", ",", "pattern", "=", "list", "(", ")", ",", "filename_only", "=", "True", ")", ":", "pattern", "=", "[", "i", ".", "lower", "(", ")", "for", "i", "in", "pattern", "]", "if", "filename_only", ":", "def", ...
Print all file that file name contains ``pattern``.
[ "Print", "all", "file", "that", "file", "name", "contains", "pattern", "." ]
689a60da51cd88680ddbe26e28dbe81e6b01d275
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/filesystem/filesystem.py#L1125-L1163
241,642
Naught0/lolrune
lolrune/aioruneclient.py
AioRuneClient._get
async def _get(self, url: str) -> str: """A small wrapper method which makes a quick GET request Parameters ---------- url : str The URL to get. Returns ------- str The raw html of the requested page. Raises ------ ...
python
async def _get(self, url: str) -> str: """A small wrapper method which makes a quick GET request Parameters ---------- url : str The URL to get. Returns ------- str The raw html of the requested page. Raises ------ ...
[ "async", "def", "_get", "(", "self", ",", "url", ":", "str", ")", "->", "str", ":", "async", "with", "self", ".", "session", ".", "get", "(", "url", ",", "headers", "=", "self", ".", "HEADERS", ")", "as", "r", ":", "if", "r", ".", "status", "==...
A small wrapper method which makes a quick GET request Parameters ---------- url : str The URL to get. Returns ------- str The raw html of the requested page. Raises ------ RuneConnectionError If the GET respo...
[ "A", "small", "wrapper", "method", "which", "makes", "a", "quick", "GET", "request" ]
99f67b9137e42a78198ba369ceb371e473759f11
https://github.com/Naught0/lolrune/blob/99f67b9137e42a78198ba369ceb371e473759f11/lolrune/aioruneclient.py#L59-L81
241,643
redbridge/molnctrl
molnctrl/csobjects.py
Virtualmachine.update
def update(self): """ Update the state """ vm = self._cs_api.list_virtualmachines(id=self.id)[0] self.is_running = self._is_running(vm.state)
python
def update(self): """ Update the state """ vm = self._cs_api.list_virtualmachines(id=self.id)[0] self.is_running = self._is_running(vm.state)
[ "def", "update", "(", "self", ")", ":", "vm", "=", "self", ".", "_cs_api", ".", "list_virtualmachines", "(", "id", "=", "self", ".", "id", ")", "[", "0", "]", "self", ".", "is_running", "=", "self", ".", "_is_running", "(", "vm", ".", "state", ")" ...
Update the state
[ "Update", "the", "state" ]
9990ae7e522ce364bb61a735f774dc28de5f8e60
https://github.com/redbridge/molnctrl/blob/9990ae7e522ce364bb61a735f774dc28de5f8e60/molnctrl/csobjects.py#L155-L158
241,644
litters/shrew
shrew/utils/auth.py
unlock_keychain
def unlock_keychain(username): """ If the user is running via SSH, their Keychain must be unlocked first. """ if 'SSH_TTY' not in os.environ: return # Don't unlock if we've already seen this user. if username in _unlocked: return _unlocked.add(username) if sys.platform == 'da...
python
def unlock_keychain(username): """ If the user is running via SSH, their Keychain must be unlocked first. """ if 'SSH_TTY' not in os.environ: return # Don't unlock if we've already seen this user. if username in _unlocked: return _unlocked.add(username) if sys.platform == 'da...
[ "def", "unlock_keychain", "(", "username", ")", ":", "if", "'SSH_TTY'", "not", "in", "os", ".", "environ", ":", "return", "# Don't unlock if we've already seen this user.", "if", "username", "in", "_unlocked", ":", "return", "_unlocked", ".", "add", "(", "username...
If the user is running via SSH, their Keychain must be unlocked first.
[ "If", "the", "user", "is", "running", "via", "SSH", "their", "Keychain", "must", "be", "unlocked", "first", "." ]
ed4b1879321d858d6bc884d14fea7557372a4d41
https://github.com/litters/shrew/blob/ed4b1879321d858d6bc884d14fea7557372a4d41/shrew/utils/auth.py#L133-L147
241,645
litters/shrew
shrew/utils/auth.py
save_password
def save_password(entry, password, username=None): """ Saves the given password in the user's keychain. :param entry: The entry in the keychain. This is a caller specific key. :param password: The password to save in the keychain. :param username: The username to get the password for. Defau...
python
def save_password(entry, password, username=None): """ Saves the given password in the user's keychain. :param entry: The entry in the keychain. This is a caller specific key. :param password: The password to save in the keychain. :param username: The username to get the password for. Defau...
[ "def", "save_password", "(", "entry", ",", "password", ",", "username", "=", "None", ")", ":", "if", "username", "is", "None", ":", "username", "=", "get_username", "(", ")", "has_keychain", "=", "initialize_keychain", "(", ")", "if", "has_keychain", ":", ...
Saves the given password in the user's keychain. :param entry: The entry in the keychain. This is a caller specific key. :param password: The password to save in the keychain. :param username: The username to get the password for. Default is the current user.
[ "Saves", "the", "given", "password", "in", "the", "user", "s", "keychain", "." ]
ed4b1879321d858d6bc884d14fea7557372a4d41
https://github.com/litters/shrew/blob/ed4b1879321d858d6bc884d14fea7557372a4d41/shrew/utils/auth.py#L150-L169
241,646
litters/shrew
shrew/utils/auth.py
remove_password
def remove_password(entry, username=None): """ Removes the password for the specific user in the user's keychain. :param entry: The entry in the keychain. This is a caller specific key. :param username: The username whose password is to be removed. Default is the current user. """ if use...
python
def remove_password(entry, username=None): """ Removes the password for the specific user in the user's keychain. :param entry: The entry in the keychain. This is a caller specific key. :param username: The username whose password is to be removed. Default is the current user. """ if use...
[ "def", "remove_password", "(", "entry", ",", "username", "=", "None", ")", ":", "if", "username", "is", "None", ":", "username", "=", "get_username", "(", ")", "has_keychain", "=", "initialize_keychain", "(", ")", "if", "has_keychain", ":", "try", ":", "ke...
Removes the password for the specific user in the user's keychain. :param entry: The entry in the keychain. This is a caller specific key. :param username: The username whose password is to be removed. Default is the current user.
[ "Removes", "the", "password", "for", "the", "specific", "user", "in", "the", "user", "s", "keychain", "." ]
ed4b1879321d858d6bc884d14fea7557372a4d41
https://github.com/litters/shrew/blob/ed4b1879321d858d6bc884d14fea7557372a4d41/shrew/utils/auth.py#L172-L191
241,647
litters/shrew
shrew/utils/auth.py
get_password
def get_password(entry=None, username=None, prompt=None, always_ask=False): """ Prompt the user for a password on stdin. :param username: The username to get the password for. Default is the current user. :param entry: The entry in the keychain. This is a caller specific key. :param prompt:...
python
def get_password(entry=None, username=None, prompt=None, always_ask=False): """ Prompt the user for a password on stdin. :param username: The username to get the password for. Default is the current user. :param entry: The entry in the keychain. This is a caller specific key. :param prompt:...
[ "def", "get_password", "(", "entry", "=", "None", ",", "username", "=", "None", ",", "prompt", "=", "None", ",", "always_ask", "=", "False", ")", ":", "password", "=", "None", "if", "username", "is", "None", ":", "username", "=", "get_username", "(", "...
Prompt the user for a password on stdin. :param username: The username to get the password for. Default is the current user. :param entry: The entry in the keychain. This is a caller specific key. :param prompt: The entry in the keychain. This is a caller specific key. :param always_ask: Force ...
[ "Prompt", "the", "user", "for", "a", "password", "on", "stdin", "." ]
ed4b1879321d858d6bc884d14fea7557372a4d41
https://github.com/litters/shrew/blob/ed4b1879321d858d6bc884d14fea7557372a4d41/shrew/utils/auth.py#L194-L223
241,648
litters/shrew
shrew/utils/auth.py
validate_password
def validate_password(entry, username, check_function, password=None, retries=1, save_on_success=True, prompt=None, **check_args): """ Validate a password with a check function & retry if the password is incorrect. Useful for after a user has changed their password in LDAP, but their local keychain ent...
python
def validate_password(entry, username, check_function, password=None, retries=1, save_on_success=True, prompt=None, **check_args): """ Validate a password with a check function & retry if the password is incorrect. Useful for after a user has changed their password in LDAP, but their local keychain ent...
[ "def", "validate_password", "(", "entry", ",", "username", ",", "check_function", ",", "password", "=", "None", ",", "retries", "=", "1", ",", "save_on_success", "=", "True", ",", "prompt", "=", "None", ",", "*", "*", "check_args", ")", ":", "if", "passw...
Validate a password with a check function & retry if the password is incorrect. Useful for after a user has changed their password in LDAP, but their local keychain entry is then out of sync. :param str entry: The keychain entry to fetch a password from. :param str username: The username to authenti...
[ "Validate", "a", "password", "with", "a", "check", "function", "&", "retry", "if", "the", "password", "is", "incorrect", "." ]
ed4b1879321d858d6bc884d14fea7557372a4d41
https://github.com/litters/shrew/blob/ed4b1879321d858d6bc884d14fea7557372a4d41/shrew/utils/auth.py#L250-L283
241,649
mayfield/shellish
shellish/rendering/traceback.py
format_exception
def format_exception(exc, indent=0, pad=' '): """ Take an exception object and return a generator with vtml formatted exception traceback lines. """ from_msg = None if exc.__cause__ is not None: indent += yield from format_exception(exc.__cause__, indent) from_msg = traceback._cause_mes...
python
def format_exception(exc, indent=0, pad=' '): """ Take an exception object and return a generator with vtml formatted exception traceback lines. """ from_msg = None if exc.__cause__ is not None: indent += yield from format_exception(exc.__cause__, indent) from_msg = traceback._cause_mes...
[ "def", "format_exception", "(", "exc", ",", "indent", "=", "0", ",", "pad", "=", "' '", ")", ":", "from_msg", "=", "None", "if", "exc", ".", "__cause__", "is", "not", "None", ":", "indent", "+=", "yield", "from", "format_exception", "(", "exc", ".", ...
Take an exception object and return a generator with vtml formatted exception traceback lines.
[ "Take", "an", "exception", "object", "and", "return", "a", "generator", "with", "vtml", "formatted", "exception", "traceback", "lines", "." ]
df0f0e4612d138c34d8cb99b66ab5b8e47f1414a
https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/rendering/traceback.py#L12-L36
241,650
mayfield/shellish
shellish/rendering/traceback.py
print_exception
def print_exception(*args, file=None, **kwargs): """ Print the formatted output of an exception object. """ for line in format_exception(*args, **kwargs): vtml.vtmlprint(line, file=file)
python
def print_exception(*args, file=None, **kwargs): """ Print the formatted output of an exception object. """ for line in format_exception(*args, **kwargs): vtml.vtmlprint(line, file=file)
[ "def", "print_exception", "(", "*", "args", ",", "file", "=", "None", ",", "*", "*", "kwargs", ")", ":", "for", "line", "in", "format_exception", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "vtml", ".", "vtmlprint", "(", "line", ",", "file...
Print the formatted output of an exception object.
[ "Print", "the", "formatted", "output", "of", "an", "exception", "object", "." ]
df0f0e4612d138c34d8cb99b66ab5b8e47f1414a
https://github.com/mayfield/shellish/blob/df0f0e4612d138c34d8cb99b66ab5b8e47f1414a/shellish/rendering/traceback.py#L39-L42
241,651
1and1/infrascope
src/infrascope/configuration.py
Configuration.create
def create(cls, config_file=None): """ Return the default configuration. """ if cls.instance is None: cls.instance = cls(config_file) # Load config file, possibly overwriting the defaults cls.instance.load_ini() if config_file and config_file != cls....
python
def create(cls, config_file=None): """ Return the default configuration. """ if cls.instance is None: cls.instance = cls(config_file) # Load config file, possibly overwriting the defaults cls.instance.load_ini() if config_file and config_file != cls....
[ "def", "create", "(", "cls", ",", "config_file", "=", "None", ")", ":", "if", "cls", ".", "instance", "is", "None", ":", "cls", ".", "instance", "=", "cls", "(", "config_file", ")", "# Load config file, possibly overwriting the defaults", "cls", ".", "instance...
Return the default configuration.
[ "Return", "the", "default", "configuration", "." ]
d7e291917e618a0a3cd6d5bfc20c6b5defd7550c
https://github.com/1and1/infrascope/blob/d7e291917e618a0a3cd6d5bfc20c6b5defd7550c/src/infrascope/configuration.py#L38-L50
241,652
1and1/infrascope
src/infrascope/configuration.py
Configuration.load_ini
def load_ini(self): """ Load the given .INI file. """ if not self.config_file: return # Load INI file ini_file = ConfigParser.SafeConfigParser() if not ini_file.read(self.config_file): raise ConfigParser.ParsingError("Global configuration file %r ...
python
def load_ini(self): """ Load the given .INI file. """ if not self.config_file: return # Load INI file ini_file = ConfigParser.SafeConfigParser() if not ini_file.read(self.config_file): raise ConfigParser.ParsingError("Global configuration file %r ...
[ "def", "load_ini", "(", "self", ")", ":", "if", "not", "self", ".", "config_file", ":", "return", "# Load INI file", "ini_file", "=", "ConfigParser", ".", "SafeConfigParser", "(", ")", "if", "not", "ini_file", ".", "read", "(", "self", ".", "config_file", ...
Load the given .INI file.
[ "Load", "the", "given", ".", "INI", "file", "." ]
d7e291917e618a0a3cd6d5bfc20c6b5defd7550c
https://github.com/1and1/infrascope/blob/d7e291917e618a0a3cd6d5bfc20c6b5defd7550c/src/infrascope/configuration.py#L74-L109
241,653
logston/py3s3
py3s3/files.py
File.multiple_chunks
def multiple_chunks(self, chunk_size=None): """ Returns ``True`` if you can expect multiple chunks. NB: If a particular file representation is in memory, subclasses should always return ``False`` -- there's no good reason to read from memory in chunks. """ if not...
python
def multiple_chunks(self, chunk_size=None): """ Returns ``True`` if you can expect multiple chunks. NB: If a particular file representation is in memory, subclasses should always return ``False`` -- there's no good reason to read from memory in chunks. """ if not...
[ "def", "multiple_chunks", "(", "self", ",", "chunk_size", "=", "None", ")", ":", "if", "not", "chunk_size", ":", "chunk_size", "=", "self", ".", "DEFAULT_CHUNK_SIZE", "return", "self", ".", "size", ">", "chunk_size" ]
Returns ``True`` if you can expect multiple chunks. NB: If a particular file representation is in memory, subclasses should always return ``False`` -- there's no good reason to read from memory in chunks.
[ "Returns", "True", "if", "you", "can", "expect", "multiple", "chunks", "." ]
1910ca60c53a53d839d6f7b09c05b555f3bfccf4
https://github.com/logston/py3s3/blob/1910ca60c53a53d839d6f7b09c05b555f3bfccf4/py3s3/files.py#L113-L123
241,654
logston/py3s3
py3s3/files.py
S3ContentFile.content
def content(self, value): """ Set content to byte string, encoding if necessary """ if isinstance(value, bytes): self._content = value else: self._content = value.encode(ENCODING) self.size = len(value)
python
def content(self, value): """ Set content to byte string, encoding if necessary """ if isinstance(value, bytes): self._content = value else: self._content = value.encode(ENCODING) self.size = len(value)
[ "def", "content", "(", "self", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "bytes", ")", ":", "self", ".", "_content", "=", "value", "else", ":", "self", ".", "_content", "=", "value", ".", "encode", "(", "ENCODING", ")", "self", ...
Set content to byte string, encoding if necessary
[ "Set", "content", "to", "byte", "string", "encoding", "if", "necessary" ]
1910ca60c53a53d839d6f7b09c05b555f3bfccf4
https://github.com/logston/py3s3/blob/1910ca60c53a53d839d6f7b09c05b555f3bfccf4/py3s3/files.py#L208-L216
241,655
logston/py3s3
py3s3/files.py
S3ContentFile.md5hash
def md5hash(self): """Return the MD5 hash string of the file content""" digest = hashlib.md5(self.content).digest() return b64_string(digest)
python
def md5hash(self): """Return the MD5 hash string of the file content""" digest = hashlib.md5(self.content).digest() return b64_string(digest)
[ "def", "md5hash", "(", "self", ")", ":", "digest", "=", "hashlib", ".", "md5", "(", "self", ".", "content", ")", ".", "digest", "(", ")", "return", "b64_string", "(", "digest", ")" ]
Return the MD5 hash string of the file content
[ "Return", "the", "MD5", "hash", "string", "of", "the", "file", "content" ]
1910ca60c53a53d839d6f7b09c05b555f3bfccf4
https://github.com/logston/py3s3/blob/1910ca60c53a53d839d6f7b09c05b555f3bfccf4/py3s3/files.py#L218-L221
241,656
logston/py3s3
py3s3/files.py
S3ContentFile.read
def read(self, chunk_size=None): """ Return chunk_size of bytes, starting from self.pos, from self.content. """ if chunk_size: data = self.content[self.pos:self.pos + chunk_size] self.pos += len(data) return data else: return self.c...
python
def read(self, chunk_size=None): """ Return chunk_size of bytes, starting from self.pos, from self.content. """ if chunk_size: data = self.content[self.pos:self.pos + chunk_size] self.pos += len(data) return data else: return self.c...
[ "def", "read", "(", "self", ",", "chunk_size", "=", "None", ")", ":", "if", "chunk_size", ":", "data", "=", "self", ".", "content", "[", "self", ".", "pos", ":", "self", ".", "pos", "+", "chunk_size", "]", "self", ".", "pos", "+=", "len", "(", "d...
Return chunk_size of bytes, starting from self.pos, from self.content.
[ "Return", "chunk_size", "of", "bytes", "starting", "from", "self", ".", "pos", "from", "self", ".", "content", "." ]
1910ca60c53a53d839d6f7b09c05b555f3bfccf4
https://github.com/logston/py3s3/blob/1910ca60c53a53d839d6f7b09c05b555f3bfccf4/py3s3/files.py#L226-L235
241,657
klmitch/appathy
appathy/utils.py
import_egg
def import_egg(string): """ Import a controller class from an egg. Uses the entry point group "appathy.controller". """ # Split the string into a distribution and a name dist, _sep, name = string.partition('#') return pkg_resources.load_entry_point(dist, 'appathy.controller', name)
python
def import_egg(string): """ Import a controller class from an egg. Uses the entry point group "appathy.controller". """ # Split the string into a distribution and a name dist, _sep, name = string.partition('#') return pkg_resources.load_entry_point(dist, 'appathy.controller', name)
[ "def", "import_egg", "(", "string", ")", ":", "# Split the string into a distribution and a name", "dist", ",", "_sep", ",", "name", "=", "string", ".", "partition", "(", "'#'", ")", "return", "pkg_resources", ".", "load_entry_point", "(", "dist", ",", "'appathy.c...
Import a controller class from an egg. Uses the entry point group "appathy.controller".
[ "Import", "a", "controller", "class", "from", "an", "egg", ".", "Uses", "the", "entry", "point", "group", "appathy", ".", "controller", "." ]
a10aa7d21d38622e984a8fe106ab37114af90dc2
https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/utils.py#L57-L66
241,658
jalanb/pysyte
pysyte/iteration.py
first
def first(sequence, message=None): """The first item in that sequence If there aren't any, raise a ValueError with that message """ try: return next(iter(sequence)) except StopIteration: raise ValueError(message or ('Sequence is empty: %s' % sequence))
python
def first(sequence, message=None): """The first item in that sequence If there aren't any, raise a ValueError with that message """ try: return next(iter(sequence)) except StopIteration: raise ValueError(message or ('Sequence is empty: %s' % sequence))
[ "def", "first", "(", "sequence", ",", "message", "=", "None", ")", ":", "try", ":", "return", "next", "(", "iter", "(", "sequence", ")", ")", "except", "StopIteration", ":", "raise", "ValueError", "(", "message", "or", "(", "'Sequence is empty: %s'", "%", ...
The first item in that sequence If there aren't any, raise a ValueError with that message
[ "The", "first", "item", "in", "that", "sequence" ]
4e278101943d1ceb1a6bcaf6ddc72052ecf13114
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/iteration.py#L7-L15
241,659
jalanb/pysyte
pysyte/iteration.py
last
def last(sequence, message=None): """The last item in that sequence If there aren't any, raise a ValueError with that message """ try: return sequence.pop() except AttributeError: return list(sequence).pop() except IndexError: raise ValueError(message or f'Sequence is em...
python
def last(sequence, message=None): """The last item in that sequence If there aren't any, raise a ValueError with that message """ try: return sequence.pop() except AttributeError: return list(sequence).pop() except IndexError: raise ValueError(message or f'Sequence is em...
[ "def", "last", "(", "sequence", ",", "message", "=", "None", ")", ":", "try", ":", "return", "sequence", ".", "pop", "(", ")", "except", "AttributeError", ":", "return", "list", "(", "sequence", ")", ".", "pop", "(", ")", "except", "IndexError", ":", ...
The last item in that sequence If there aren't any, raise a ValueError with that message
[ "The", "last", "item", "in", "that", "sequence" ]
4e278101943d1ceb1a6bcaf6ddc72052ecf13114
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/iteration.py#L18-L28
241,660
jalanb/pysyte
pysyte/iteration.py
first_that
def first_that(predicate, sequence, message=None): """The first item in that sequence that matches that predicate If none matches raise a KeyError with that message """ try: return next(ifilter(predicate, sequence)) except StopIteration: raise KeyError(message or 'Not Found')
python
def first_that(predicate, sequence, message=None): """The first item in that sequence that matches that predicate If none matches raise a KeyError with that message """ try: return next(ifilter(predicate, sequence)) except StopIteration: raise KeyError(message or 'Not Found')
[ "def", "first_that", "(", "predicate", ",", "sequence", ",", "message", "=", "None", ")", ":", "try", ":", "return", "next", "(", "ifilter", "(", "predicate", ",", "sequence", ")", ")", "except", "StopIteration", ":", "raise", "KeyError", "(", "message", ...
The first item in that sequence that matches that predicate If none matches raise a KeyError with that message
[ "The", "first", "item", "in", "that", "sequence", "that", "matches", "that", "predicate" ]
4e278101943d1ceb1a6bcaf6ddc72052ecf13114
https://github.com/jalanb/pysyte/blob/4e278101943d1ceb1a6bcaf6ddc72052ecf13114/pysyte/iteration.py#L38-L46
241,661
MacHu-GWU/angora-project
angora/math/img2waveform.py
expand_window
def expand_window(center, window_size, array_size): """Generate a bounded windows. maxlength = 2 * window_size + 1, lower bound is 0 and upper bound is ``array_size - 1``. Example:: >>> expand_window(center=50, window_size=3, max=100) [47, 48, 49, 50, 51, 52, 53] >>> expand...
python
def expand_window(center, window_size, array_size): """Generate a bounded windows. maxlength = 2 * window_size + 1, lower bound is 0 and upper bound is ``array_size - 1``. Example:: >>> expand_window(center=50, window_size=3, max=100) [47, 48, 49, 50, 51, 52, 53] >>> expand...
[ "def", "expand_window", "(", "center", ",", "window_size", ",", "array_size", ")", ":", "if", "center", "-", "window_size", "<", "0", ":", "lower", "=", "0", "else", ":", "lower", "=", "center", "-", "window_size", "if", "center", "+", "window_size", "+"...
Generate a bounded windows. maxlength = 2 * window_size + 1, lower bound is 0 and upper bound is ``array_size - 1``. Example:: >>> expand_window(center=50, window_size=3, max=100) [47, 48, 49, 50, 51, 52, 53] >>> expand_window(center=2, window_size=3, max=100) [0, 1, 2,...
[ "Generate", "a", "bounded", "windows", "." ]
689a60da51cd88680ddbe26e28dbe81e6b01d275
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/math/img2waveform.py#L44-L69
241,662
MacHu-GWU/angora-project
angora/math/img2waveform.py
img2ascii
def img2ascii(img_path, ascii_path, ascii_char="*", pad=0): """Convert an image to ascii art text. Suppose we have an image like that: .. image:: images/rabbit.png :align: left Put some codes:: >>> from weatherlab.math.img2waveform import img2ascii >>> img2ascii(r"testdata\im...
python
def img2ascii(img_path, ascii_path, ascii_char="*", pad=0): """Convert an image to ascii art text. Suppose we have an image like that: .. image:: images/rabbit.png :align: left Put some codes:: >>> from weatherlab.math.img2waveform import img2ascii >>> img2ascii(r"testdata\im...
[ "def", "img2ascii", "(", "img_path", ",", "ascii_path", ",", "ascii_char", "=", "\"*\"", ",", "pad", "=", "0", ")", ":", "if", "len", "(", "ascii_char", ")", "!=", "1", ":", "raise", "Exception", "(", "\"ascii_char has to be single character.\"", ")", "image...
Convert an image to ascii art text. Suppose we have an image like that: .. image:: images/rabbit.png :align: left Put some codes:: >>> from weatherlab.math.img2waveform import img2ascii >>> img2ascii(r"testdata\img2waveform\rabbit.png", ... r"testdata\img2wavef...
[ "Convert", "an", "image", "to", "ascii", "art", "text", "." ]
689a60da51cd88680ddbe26e28dbe81e6b01d275
https://github.com/MacHu-GWU/angora-project/blob/689a60da51cd88680ddbe26e28dbe81e6b01d275/angora/math/img2waveform.py#L72-L261
241,663
Fuyukai/ConfigMaster
configmaster/ConfigFile.py
ConfigObject.initial_populate
def initial_populate(self, data): """ Populate a newly created config object with data. If it was populated, this returns True. If it wasn't, this returns False. It is recommended to run a .dump() and .reload() after running this. """ if self.config.parsed: ...
python
def initial_populate(self, data): """ Populate a newly created config object with data. If it was populated, this returns True. If it wasn't, this returns False. It is recommended to run a .dump() and .reload() after running this. """ if self.config.parsed: ...
[ "def", "initial_populate", "(", "self", ",", "data", ")", ":", "if", "self", ".", "config", ".", "parsed", ":", "return", "False", "# Otherwise, create a new ConfigKey.", "self", ".", "config", ".", "load_from_dict", "(", "data", ")", "return", "True" ]
Populate a newly created config object with data. If it was populated, this returns True. If it wasn't, this returns False. It is recommended to run a .dump() and .reload() after running this.
[ "Populate", "a", "newly", "created", "config", "object", "with", "data", "." ]
8018aa415da55c84edaa8a49664f674758a14edd
https://github.com/Fuyukai/ConfigMaster/blob/8018aa415da55c84edaa8a49664f674758a14edd/configmaster/ConfigFile.py#L67-L79
241,664
Fuyukai/ConfigMaster
configmaster/ConfigFile.py
ConfigObject.apply_defaults
def apply_defaults(self, other_config): """ Applies default values from a different ConfigObject or ConfigKey object to this ConfigObject. If there are any values in this object that are also in the default object, it will use the values from this object. """ if isinstance(other...
python
def apply_defaults(self, other_config): """ Applies default values from a different ConfigObject or ConfigKey object to this ConfigObject. If there are any values in this object that are also in the default object, it will use the values from this object. """ if isinstance(other...
[ "def", "apply_defaults", "(", "self", ",", "other_config", ")", ":", "if", "isinstance", "(", "other_config", ",", "self", ".", "__class__", ")", ":", "self", ".", "config", ".", "load_from_dict", "(", "other_config", ".", "config", ",", "overwrite", "=", ...
Applies default values from a different ConfigObject or ConfigKey object to this ConfigObject. If there are any values in this object that are also in the default object, it will use the values from this object.
[ "Applies", "default", "values", "from", "a", "different", "ConfigObject", "or", "ConfigKey", "object", "to", "this", "ConfigObject", "." ]
8018aa415da55c84edaa8a49664f674758a14edd
https://github.com/Fuyukai/ConfigMaster/blob/8018aa415da55c84edaa8a49664f674758a14edd/configmaster/ConfigFile.py#L81-L90
241,665
Fuyukai/ConfigMaster
configmaster/ConfigFile.py
ConfigFile.reload
def reload(self): """ Automatically reloads the config file. This is just an alias for self.load().""" if not self.fd.closed: self.fd.close() self.fd = open(self.fd.name, 'r') self.load()
python
def reload(self): """ Automatically reloads the config file. This is just an alias for self.load().""" if not self.fd.closed: self.fd.close() self.fd = open(self.fd.name, 'r') self.load()
[ "def", "reload", "(", "self", ")", ":", "if", "not", "self", ".", "fd", ".", "closed", ":", "self", ".", "fd", ".", "close", "(", ")", "self", ".", "fd", "=", "open", "(", "self", ".", "fd", ".", "name", ",", "'r'", ")", "self", ".", "load", ...
Automatically reloads the config file. This is just an alias for self.load().
[ "Automatically", "reloads", "the", "config", "file", "." ]
8018aa415da55c84edaa8a49664f674758a14edd
https://github.com/Fuyukai/ConfigMaster/blob/8018aa415da55c84edaa8a49664f674758a14edd/configmaster/ConfigFile.py#L155-L164
241,666
Fuyukai/ConfigMaster
configmaster/ConfigFile.py
NetworkedConfigObject.save_to_file
def save_to_file(self, filename: str) -> ConfigFile: """ This converts the NetworkedConfigFile into a normal ConfigFile object. This requires the normal class hooks to be provided. """ newclass = ConfigFile(fd=filename, load_hook=self.normal_class_hook[0], ...
python
def save_to_file(self, filename: str) -> ConfigFile: """ This converts the NetworkedConfigFile into a normal ConfigFile object. This requires the normal class hooks to be provided. """ newclass = ConfigFile(fd=filename, load_hook=self.normal_class_hook[0], ...
[ "def", "save_to_file", "(", "self", ",", "filename", ":", "str", ")", "->", "ConfigFile", ":", "newclass", "=", "ConfigFile", "(", "fd", "=", "filename", ",", "load_hook", "=", "self", ".", "normal_class_hook", "[", "0", "]", ",", "dump_hook", "=", "self...
This converts the NetworkedConfigFile into a normal ConfigFile object. This requires the normal class hooks to be provided.
[ "This", "converts", "the", "NetworkedConfigFile", "into", "a", "normal", "ConfigFile", "object", "." ]
8018aa415da55c84edaa8a49664f674758a14edd
https://github.com/Fuyukai/ConfigMaster/blob/8018aa415da55c84edaa8a49664f674758a14edd/configmaster/ConfigFile.py#L203-L211
241,667
robertchase/ergaleia
ergaleia/to_args.py
to_args
def to_args(s): """ parse a string into args and kwargs the input is a blank-delimited set of tokens, which may be grouped as strings (tick or double tick delimited) with embedded blanks. a non-string equal (=) acts as a delimiter between key-value pairs. the initial tokens are tre...
python
def to_args(s): """ parse a string into args and kwargs the input is a blank-delimited set of tokens, which may be grouped as strings (tick or double tick delimited) with embedded blanks. a non-string equal (=) acts as a delimiter between key-value pairs. the initial tokens are tre...
[ "def", "to_args", "(", "s", ")", ":", "args", "=", "[", "]", "kwargs", "=", "{", "}", "state", "=", "'arg'", "for", "token", "in", "to_tokens", "(", "s", ")", ":", "if", "state", "==", "'arg'", ":", "if", "token", ".", "is_key", ":", "key", "="...
parse a string into args and kwargs the input is a blank-delimited set of tokens, which may be grouped as strings (tick or double tick delimited) with embedded blanks. a non-string equal (=) acts as a delimiter between key-value pairs. the initial tokens are treated as args, followed b...
[ "parse", "a", "string", "into", "args", "and", "kwargs" ]
df8e9a4b18c563022a503faa27e822c9a5755490
https://github.com/robertchase/ergaleia/blob/df8e9a4b18c563022a503faa27e822c9a5755490/ergaleia/to_args.py#L8-L70
241,668
klmitch/appathy
appathy/application.py
Application.dispatch
def dispatch(self, req): """ Called by the Routes middleware to dispatch the request to the appropriate controller. If a webob exception is raised, it is returned; if some other exception is raised, the webob `HTTPInternalServerError` exception is raised. Otherwise, the ...
python
def dispatch(self, req): """ Called by the Routes middleware to dispatch the request to the appropriate controller. If a webob exception is raised, it is returned; if some other exception is raised, the webob `HTTPInternalServerError` exception is raised. Otherwise, the ...
[ "def", "dispatch", "(", "self", ",", "req", ")", ":", "# Grab the request parameters", "params", "=", "req", ".", "environ", "[", "'wsgiorg.routing_args'", "]", "[", "1", "]", "# What controller is authoritative?", "controller", "=", "params", ".", "pop", "(", "...
Called by the Routes middleware to dispatch the request to the appropriate controller. If a webob exception is raised, it is returned; if some other exception is raised, the webob `HTTPInternalServerError` exception is raised. Otherwise, the return value of the controller is returned.
[ "Called", "by", "the", "Routes", "middleware", "to", "dispatch", "the", "request", "to", "the", "appropriate", "controller", ".", "If", "a", "webob", "exception", "is", "raised", "it", "is", "returned", ";", "if", "some", "other", "exception", "is", "raised"...
a10aa7d21d38622e984a8fe106ab37114af90dc2
https://github.com/klmitch/appathy/blob/a10aa7d21d38622e984a8fe106ab37114af90dc2/appathy/application.py#L110-L154
241,669
shaded-enmity/docker-hica
base/hica_base.py
HicaLabelStore.query
def query(self, ns, selector='*'): """ Query the label store for labels :param ns: Label namespace (`bind_pwd` for example) :type ns: str :param selector: Target selector (`test` or `test.guest` for example) :type selector: str """ q, r = HicaLabelStore.PREFIX + '.' + ns, [] for (k...
python
def query(self, ns, selector='*'): """ Query the label store for labels :param ns: Label namespace (`bind_pwd` for example) :type ns: str :param selector: Target selector (`test` or `test.guest` for example) :type selector: str """ q, r = HicaLabelStore.PREFIX + '.' + ns, [] for (k...
[ "def", "query", "(", "self", ",", "ns", ",", "selector", "=", "'*'", ")", ":", "q", ",", "r", "=", "HicaLabelStore", ".", "PREFIX", "+", "'.'", "+", "ns", ",", "[", "]", "for", "(", "key", ",", "value", ")", "in", "self", ".", "items", ":", "...
Query the label store for labels :param ns: Label namespace (`bind_pwd` for example) :type ns: str :param selector: Target selector (`test` or `test.guest` for example) :type selector: str
[ "Query", "the", "label", "store", "for", "labels" ]
bc425586297e1eb228b70ee6fca8c499849ec87d
https://github.com/shaded-enmity/docker-hica/blob/bc425586297e1eb228b70ee6fca8c499849ec87d/base/hica_base.py#L63-L81
241,670
shaded-enmity/docker-hica
base/hica_base.py
HicaLabelStore.get_value
def get_value(self, label): """ Get value from a single fully-qualified name """ for (key, value) in self.items: if key == label: return value
python
def get_value(self, label): """ Get value from a single fully-qualified name """ for (key, value) in self.items: if key == label: return value
[ "def", "get_value", "(", "self", ",", "label", ")", ":", "for", "(", "key", ",", "value", ")", "in", "self", ".", "items", ":", "if", "key", "==", "label", ":", "return", "value" ]
Get value from a single fully-qualified name
[ "Get", "value", "from", "a", "single", "fully", "-", "qualified", "name" ]
bc425586297e1eb228b70ee6fca8c499849ec87d
https://github.com/shaded-enmity/docker-hica/blob/bc425586297e1eb228b70ee6fca8c499849ec87d/base/hica_base.py#L87-L91
241,671
vilmibm/done
parsedatetime/parsedatetime_consts.py
_initPatterns
def _initPatterns(ptc): """ Helper function to take the different localized bits from ptc and create the regex strings. """ # TODO add code to parse the date formats and build the regexes up from sub-parts # TODO find all hard-coded uses of date/time seperators ptc.RE_DATE4 = r'''(?P<da...
python
def _initPatterns(ptc): """ Helper function to take the different localized bits from ptc and create the regex strings. """ # TODO add code to parse the date formats and build the regexes up from sub-parts # TODO find all hard-coded uses of date/time seperators ptc.RE_DATE4 = r'''(?P<da...
[ "def", "_initPatterns", "(", "ptc", ")", ":", "# TODO add code to parse the date formats and build the regexes up from sub-parts", "# TODO find all hard-coded uses of date/time seperators", "ptc", ".", "RE_DATE4", "=", "r'''(?P<date>(((?P<day>\\d\\d?)(?P<suffix>%(daysuffix)s)?(,)?(\\s)?)\n ...
Helper function to take the different localized bits from ptc and create the regex strings.
[ "Helper", "function", "to", "take", "the", "different", "localized", "bits", "from", "ptc", "and", "create", "the", "regex", "strings", "." ]
7e5b60d2900ceddefa49de352a19b794199b51a8
https://github.com/vilmibm/done/blob/7e5b60d2900ceddefa49de352a19b794199b51a8/parsedatetime/parsedatetime_consts.py#L710-L838
241,672
vilmibm/done
parsedatetime/parsedatetime_consts.py
_initConstants
def _initConstants(ptc): """ Create localized versions of the units, week and month names """ # build weekday offsets - yes, it assumes the Weekday and shortWeekday # lists are in the same order and Mon..Sun (Python style) ptc.WeekdayOffsets = {} o = 0 for key in ptc.Weekdays: ...
python
def _initConstants(ptc): """ Create localized versions of the units, week and month names """ # build weekday offsets - yes, it assumes the Weekday and shortWeekday # lists are in the same order and Mon..Sun (Python style) ptc.WeekdayOffsets = {} o = 0 for key in ptc.Weekdays: ...
[ "def", "_initConstants", "(", "ptc", ")", ":", "# build weekday offsets - yes, it assumes the Weekday and shortWeekday", "# lists are in the same order and Mon..Sun (Python style)", "ptc", ".", "WeekdayOffsets", "=", "{", "}", "o", "=", "0", "for", "key", "in", "ptc", ".", ...
Create localized versions of the units, week and month names
[ "Create", "localized", "versions", "of", "the", "units", "week", "and", "month", "names" ]
7e5b60d2900ceddefa49de352a19b794199b51a8
https://github.com/vilmibm/done/blob/7e5b60d2900ceddefa49de352a19b794199b51a8/parsedatetime/parsedatetime_consts.py#L841-L869
241,673
krinj/k-util
k_util/serializable.py
Serializable.write_to_file
def write_to_file(self, file_path: str) -> None: """ Serialize and write the data into a JSON file. """ data = self.encode() with open(file_path, "w") as f: json.dump(data, f, indent=1)
python
def write_to_file(self, file_path: str) -> None: """ Serialize and write the data into a JSON file. """ data = self.encode() with open(file_path, "w") as f: json.dump(data, f, indent=1)
[ "def", "write_to_file", "(", "self", ",", "file_path", ":", "str", ")", "->", "None", ":", "data", "=", "self", ".", "encode", "(", ")", "with", "open", "(", "file_path", ",", "\"w\"", ")", "as", "f", ":", "json", ".", "dump", "(", "data", ",", "...
Serialize and write the data into a JSON file.
[ "Serialize", "and", "write", "the", "data", "into", "a", "JSON", "file", "." ]
b118826b1d6f49ca4e1ca7327d5b171db332ac23
https://github.com/krinj/k-util/blob/b118826b1d6f49ca4e1ca7327d5b171db332ac23/k_util/serializable.py#L54-L58
241,674
krinj/k-util
k_util/serializable.py
Serializable.load_from_file
def load_from_file(cls, file_path: str): """ Read and reconstruct the data from a JSON file. """ with open(file_path, "r") as f: data = json.load(f) item = cls.decode(data=data) return item
python
def load_from_file(cls, file_path: str): """ Read and reconstruct the data from a JSON file. """ with open(file_path, "r") as f: data = json.load(f) item = cls.decode(data=data) return item
[ "def", "load_from_file", "(", "cls", ",", "file_path", ":", "str", ")", ":", "with", "open", "(", "file_path", ",", "\"r\"", ")", "as", "f", ":", "data", "=", "json", ".", "load", "(", "f", ")", "item", "=", "cls", ".", "decode", "(", "data", "="...
Read and reconstruct the data from a JSON file.
[ "Read", "and", "reconstruct", "the", "data", "from", "a", "JSON", "file", "." ]
b118826b1d6f49ca4e1ca7327d5b171db332ac23
https://github.com/krinj/k-util/blob/b118826b1d6f49ca4e1ca7327d5b171db332ac23/k_util/serializable.py#L61-L66
241,675
fr33jc/bang
bang/providers/bases.py
Provider.gen_component_name
def gen_component_name(self, basename, postfix_length=13): """ Creates a resource identifier with a random postfix. This is an attempt to minimize name collisions in provider namespaces. :param str basename: The string that will be prefixed with the stack name, and postfix...
python
def gen_component_name(self, basename, postfix_length=13): """ Creates a resource identifier with a random postfix. This is an attempt to minimize name collisions in provider namespaces. :param str basename: The string that will be prefixed with the stack name, and postfix...
[ "def", "gen_component_name", "(", "self", ",", "basename", ",", "postfix_length", "=", "13", ")", ":", "def", "newcname", "(", ")", ":", "postfix", "=", "''", ".", "join", "(", "random", ".", "choice", "(", "_AWS_NAME_CHARS", ")", "for", "i", "in", "xr...
Creates a resource identifier with a random postfix. This is an attempt to minimize name collisions in provider namespaces. :param str basename: The string that will be prefixed with the stack name, and postfixed with some random string. :param int postfix_length: The length of ...
[ "Creates", "a", "resource", "identifier", "with", "a", "random", "postfix", ".", "This", "is", "an", "attempt", "to", "minimize", "name", "collisions", "in", "provider", "namespaces", "." ]
8f000713f88d2a9a8c1193b63ca10a6578560c16
https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/bases.py#L32-L53
241,676
political-memory/django-representatives
representatives/migrations/0020_rep_unique_slug_remove_remoteid.py
update_slugs
def update_slugs(apps, schema_editor): """ Include birthdate in slugs """ # Get model managers Representative = apps.get_model("representatives", "Representative") for rep in Representative.objects.all(): rep.slug = '%s-%s' % (rep.slug, rep.birth_date) rep.save()
python
def update_slugs(apps, schema_editor): """ Include birthdate in slugs """ # Get model managers Representative = apps.get_model("representatives", "Representative") for rep in Representative.objects.all(): rep.slug = '%s-%s' % (rep.slug, rep.birth_date) rep.save()
[ "def", "update_slugs", "(", "apps", ",", "schema_editor", ")", ":", "# Get model managers", "Representative", "=", "apps", ".", "get_model", "(", "\"representatives\"", ",", "\"Representative\"", ")", "for", "rep", "in", "Representative", ".", "objects", ".", "all...
Include birthdate in slugs
[ "Include", "birthdate", "in", "slugs" ]
811c90d0250149e913e6196f0ab11c97d396be39
https://github.com/political-memory/django-representatives/blob/811c90d0250149e913e6196f0ab11c97d396be39/representatives/migrations/0020_rep_unique_slug_remove_remoteid.py#L9-L19
241,677
political-memory/django-representatives
representatives/migrations/0020_rep_unique_slug_remove_remoteid.py
create_parl_websites
def create_parl_websites(apps, schema_editor): """ Prepare for remote_id removal by creating WebSite entities from it. """ # Get model managers Representative = apps.get_model("representatives", "Representative") WebSite = apps.get_model("representatives", "WebSite") today = datetime.date....
python
def create_parl_websites(apps, schema_editor): """ Prepare for remote_id removal by creating WebSite entities from it. """ # Get model managers Representative = apps.get_model("representatives", "Representative") WebSite = apps.get_model("representatives", "WebSite") today = datetime.date....
[ "def", "create_parl_websites", "(", "apps", ",", "schema_editor", ")", ":", "# Get model managers", "Representative", "=", "apps", ".", "get_model", "(", "\"representatives\"", ",", "\"Representative\"", ")", "WebSite", "=", "apps", ".", "get_model", "(", "\"represe...
Prepare for remote_id removal by creating WebSite entities from it.
[ "Prepare", "for", "remote_id", "removal", "by", "creating", "WebSite", "entities", "from", "it", "." ]
811c90d0250149e913e6196f0ab11c97d396be39
https://github.com/political-memory/django-representatives/blob/811c90d0250149e913e6196f0ab11c97d396be39/representatives/migrations/0020_rep_unique_slug_remove_remoteid.py#L22-L79
241,678
phenicle/cfgpy
cfgpy/tools.py
determine_file_extension_based_on_format
def determine_file_extension_based_on_format(format_specifier): """ returns file extension string """ if format_specifier == FMT_INI: return 'ini' if format_specifier == FMT_DELIMITED: return '' if format_specifier == FMT_XML: return 'xml' if format_specifier == FMT_JSON: return 'json' if format_specifier...
python
def determine_file_extension_based_on_format(format_specifier): """ returns file extension string """ if format_specifier == FMT_INI: return 'ini' if format_specifier == FMT_DELIMITED: return '' if format_specifier == FMT_XML: return 'xml' if format_specifier == FMT_JSON: return 'json' if format_specifier...
[ "def", "determine_file_extension_based_on_format", "(", "format_specifier", ")", ":", "if", "format_specifier", "==", "FMT_INI", ":", "return", "'ini'", "if", "format_specifier", "==", "FMT_DELIMITED", ":", "return", "''", "if", "format_specifier", "==", "FMT_XML", ":...
returns file extension string
[ "returns", "file", "extension", "string" ]
d53a9ad4c91cdcd774b59cf3b8c59096fdf29d20
https://github.com/phenicle/cfgpy/blob/d53a9ad4c91cdcd774b59cf3b8c59096fdf29d20/cfgpy/tools.py#L19-L31
241,679
phenicle/cfgpy
cfgpy/tools.py
CfgPy.read_element_using_argtuple
def read_element_using_argtuple(self, argtuple): """ takes a tuple of keys returns node found in cfg_dict found by traversing cfg_dict by successive application of keys from element_path """ # doesn't support DELIMITED, only dict-based formats if self.format == FMT_DELIMITED: return None node = ...
python
def read_element_using_argtuple(self, argtuple): """ takes a tuple of keys returns node found in cfg_dict found by traversing cfg_dict by successive application of keys from element_path """ # doesn't support DELIMITED, only dict-based formats if self.format == FMT_DELIMITED: return None node = ...
[ "def", "read_element_using_argtuple", "(", "self", ",", "argtuple", ")", ":", "# doesn't support DELIMITED, only dict-based formats", "if", "self", ".", "format", "==", "FMT_DELIMITED", ":", "return", "None", "node", "=", "self", ".", "cfg_dict", "for", "key", "in",...
takes a tuple of keys returns node found in cfg_dict found by traversing cfg_dict by successive application of keys from element_path
[ "takes", "a", "tuple", "of", "keys", "returns", "node", "found", "in", "cfg_dict", "found", "by", "traversing", "cfg_dict", "by", "successive", "application", "of", "keys", "from", "element_path" ]
d53a9ad4c91cdcd774b59cf3b8c59096fdf29d20
https://github.com/phenicle/cfgpy/blob/d53a9ad4c91cdcd774b59cf3b8c59096fdf29d20/cfgpy/tools.py#L144-L159
241,680
maceoutliner/django-fiction-outlines
fiction_outlines/models.py
Outline.create_arc
def create_arc(self, mace_type, name): ''' Creates the story arc and initial tree for that arc for the current outline. Returns the resulting Arc instance. ''' arc = Arc(mace_type=mace_type, outline=self, name=name) arc.save() milestone_count = arc.generat...
python
def create_arc(self, mace_type, name): ''' Creates the story arc and initial tree for that arc for the current outline. Returns the resulting Arc instance. ''' arc = Arc(mace_type=mace_type, outline=self, name=name) arc.save() milestone_count = arc.generat...
[ "def", "create_arc", "(", "self", ",", "mace_type", ",", "name", ")", ":", "arc", "=", "Arc", "(", "mace_type", "=", "mace_type", ",", "outline", "=", "self", ",", "name", "=", "name", ")", "arc", ".", "save", "(", ")", "milestone_count", "=", "arc",...
Creates the story arc and initial tree for that arc for the current outline. Returns the resulting Arc instance.
[ "Creates", "the", "story", "arc", "and", "initial", "tree", "for", "that", "arc", "for", "the", "current", "outline", ".", "Returns", "the", "resulting", "Arc", "instance", "." ]
6c58e356af3fbe7b23557643ba27e46eaef9d4e3
https://github.com/maceoutliner/django-fiction-outlines/blob/6c58e356af3fbe7b23557643ba27e46eaef9d4e3/fiction_outlines/models.py#L410-L423
241,681
maceoutliner/django-fiction-outlines
fiction_outlines/models.py
Arc.generate_template_arc_tree
def generate_template_arc_tree(self): ''' Generate a seven point template in this arc. Arc must be empty. ''' arc_root = self.arc_root_node if not arc_root: arc_root = ArcElementNode.add_root( arc_element_type='root', description='root ...
python
def generate_template_arc_tree(self): ''' Generate a seven point template in this arc. Arc must be empty. ''' arc_root = self.arc_root_node if not arc_root: arc_root = ArcElementNode.add_root( arc_element_type='root', description='root ...
[ "def", "generate_template_arc_tree", "(", "self", ")", ":", "arc_root", "=", "self", ".", "arc_root_node", "if", "not", "arc_root", ":", "arc_root", "=", "ArcElementNode", ".", "add_root", "(", "arc_element_type", "=", "'root'", ",", "description", "=", "'root o...
Generate a seven point template in this arc. Arc must be empty.
[ "Generate", "a", "seven", "point", "template", "in", "this", "arc", ".", "Arc", "must", "be", "empty", "." ]
6c58e356af3fbe7b23557643ba27e46eaef9d4e3
https://github.com/maceoutliner/django-fiction-outlines/blob/6c58e356af3fbe7b23557643ba27e46eaef9d4e3/fiction_outlines/models.py#L602-L619
241,682
maceoutliner/django-fiction-outlines
fiction_outlines/models.py
Arc.fetch_arc_errors
def fetch_arc_errors(self): ''' Evaluates the current tree of the arc and provides a list of errors that the user should correct. ''' error_list = [] hnode = self.validate_first_element() if hnode: error_list.append({'hook_error': hnode}) rnode...
python
def fetch_arc_errors(self): ''' Evaluates the current tree of the arc and provides a list of errors that the user should correct. ''' error_list = [] hnode = self.validate_first_element() if hnode: error_list.append({'hook_error': hnode}) rnode...
[ "def", "fetch_arc_errors", "(", "self", ")", ":", "error_list", "=", "[", "]", "hnode", "=", "self", ".", "validate_first_element", "(", ")", "if", "hnode", ":", "error_list", ".", "append", "(", "{", "'hook_error'", ":", "hnode", "}", ")", "rnode", "=",...
Evaluates the current tree of the arc and provides a list of errors that the user should correct.
[ "Evaluates", "the", "current", "tree", "of", "the", "arc", "and", "provides", "a", "list", "of", "errors", "that", "the", "user", "should", "correct", "." ]
6c58e356af3fbe7b23557643ba27e46eaef9d4e3
https://github.com/maceoutliner/django-fiction-outlines/blob/6c58e356af3fbe7b23557643ba27e46eaef9d4e3/fiction_outlines/models.py#L621-L640
241,683
maceoutliner/django-fiction-outlines
fiction_outlines/models.py
Arc.validate_generations
def validate_generations(self): ''' Make sure that the descendent depth is valid. ''' nodes = self.arc_root_node.get_descendants() for node in nodes: logger.debug("Checking parent for node of type %s" % node.arc_element_type) parent = ArcElementNode.object...
python
def validate_generations(self): ''' Make sure that the descendent depth is valid. ''' nodes = self.arc_root_node.get_descendants() for node in nodes: logger.debug("Checking parent for node of type %s" % node.arc_element_type) parent = ArcElementNode.object...
[ "def", "validate_generations", "(", "self", ")", ":", "nodes", "=", "self", ".", "arc_root_node", ".", "get_descendants", "(", ")", "for", "node", "in", "nodes", ":", "logger", ".", "debug", "(", "\"Checking parent for node of type %s\"", "%", "node", ".", "ar...
Make sure that the descendent depth is valid.
[ "Make", "sure", "that", "the", "descendent", "depth", "is", "valid", "." ]
6c58e356af3fbe7b23557643ba27e46eaef9d4e3
https://github.com/maceoutliner/django-fiction-outlines/blob/6c58e356af3fbe7b23557643ba27e46eaef9d4e3/fiction_outlines/models.py#L660-L674
241,684
maceoutliner/django-fiction-outlines
fiction_outlines/models.py
Arc.validate_milestones
def validate_milestones(self): ''' Reviews the arc element tree to ensure that milestones appear in the right order. ''' milestones = self.arc_root_node.get_children().filter(arc_element_type__contains='mile') current_cursor = 0 for mile in milestones: ...
python
def validate_milestones(self): ''' Reviews the arc element tree to ensure that milestones appear in the right order. ''' milestones = self.arc_root_node.get_children().filter(arc_element_type__contains='mile') current_cursor = 0 for mile in milestones: ...
[ "def", "validate_milestones", "(", "self", ")", ":", "milestones", "=", "self", ".", "arc_root_node", ".", "get_children", "(", ")", ".", "filter", "(", "arc_element_type__contains", "=", "'mile'", ")", "current_cursor", "=", "0", "for", "mile", "in", "milesto...
Reviews the arc element tree to ensure that milestones appear in the right order.
[ "Reviews", "the", "arc", "element", "tree", "to", "ensure", "that", "milestones", "appear", "in", "the", "right", "order", "." ]
6c58e356af3fbe7b23557643ba27e46eaef9d4e3
https://github.com/maceoutliner/django-fiction-outlines/blob/6c58e356af3fbe7b23557643ba27e46eaef9d4e3/fiction_outlines/models.py#L676-L688
241,685
maceoutliner/django-fiction-outlines
fiction_outlines/models.py
StoryElementNode.all_characters
def all_characters(self): ''' Returns a queryset of all characters associated with this node and its descendants, excluding any duplicates. ''' qs = self.assoc_characters.all() for node in self.get_descendants(): qs2 = node.assoc_characters.all() q...
python
def all_characters(self): ''' Returns a queryset of all characters associated with this node and its descendants, excluding any duplicates. ''' qs = self.assoc_characters.all() for node in self.get_descendants(): qs2 = node.assoc_characters.all() q...
[ "def", "all_characters", "(", "self", ")", ":", "qs", "=", "self", ".", "assoc_characters", ".", "all", "(", ")", "for", "node", "in", "self", ".", "get_descendants", "(", ")", ":", "qs2", "=", "node", ".", "assoc_characters", ".", "all", "(", ")", "...
Returns a queryset of all characters associated with this node and its descendants, excluding any duplicates.
[ "Returns", "a", "queryset", "of", "all", "characters", "associated", "with", "this", "node", "and", "its", "descendants", "excluding", "any", "duplicates", "." ]
6c58e356af3fbe7b23557643ba27e46eaef9d4e3
https://github.com/maceoutliner/django-fiction-outlines/blob/6c58e356af3fbe7b23557643ba27e46eaef9d4e3/fiction_outlines/models.py#L817-L826
241,686
maceoutliner/django-fiction-outlines
fiction_outlines/models.py
StoryElementNode.impact_rating
def impact_rating(self): ''' Returns the impact rating for this node. Impact rating is a measure of how powerful this moment in the story is by evaluting how many simultaneous arc elements are associated with it. There is also a generational bleed element, where the impact score ...
python
def impact_rating(self): ''' Returns the impact rating for this node. Impact rating is a measure of how powerful this moment in the story is by evaluting how many simultaneous arc elements are associated with it. There is also a generational bleed element, where the impact score ...
[ "def", "impact_rating", "(", "self", ")", ":", "if", "self", ".", "depth", "==", "1", ":", "logger", ".", "debug", "(", "'Root node. Skipping.'", ")", "return", "0", "# pragma: no cover", "impact_bleed", "=", "{", "'mile'", ":", "0.5", ",", "# A milestone ex...
Returns the impact rating for this node. Impact rating is a measure of how powerful this moment in the story is by evaluting how many simultaneous arc elements are associated with it. There is also a generational bleed element, where the impact score creates shockwaves throughout their direct an...
[ "Returns", "the", "impact", "rating", "for", "this", "node", ".", "Impact", "rating", "is", "a", "measure", "of", "how", "powerful", "this", "moment", "in", "the", "story", "is", "by", "evaluting", "how", "many", "simultaneous", "arc", "elements", "are", "...
6c58e356af3fbe7b23557643ba27e46eaef9d4e3
https://github.com/maceoutliner/django-fiction-outlines/blob/6c58e356af3fbe7b23557643ba27e46eaef9d4e3/fiction_outlines/models.py#L829-L878
241,687
maceoutliner/django-fiction-outlines
fiction_outlines/models.py
StoryElementNode.all_locations
def all_locations(self): ''' Returns a queryset of all locations associated with this node and its descendants, excluding any duplicates. ''' qs = self.assoc_locations.all() for node in self.get_descendants(): qs2 = node.assoc_locations.all() qs = ...
python
def all_locations(self): ''' Returns a queryset of all locations associated with this node and its descendants, excluding any duplicates. ''' qs = self.assoc_locations.all() for node in self.get_descendants(): qs2 = node.assoc_locations.all() qs = ...
[ "def", "all_locations", "(", "self", ")", ":", "qs", "=", "self", ".", "assoc_locations", ".", "all", "(", ")", "for", "node", "in", "self", ".", "get_descendants", "(", ")", ":", "qs2", "=", "node", ".", "assoc_locations", ".", "all", "(", ")", "qs"...
Returns a queryset of all locations associated with this node and its descendants, excluding any duplicates.
[ "Returns", "a", "queryset", "of", "all", "locations", "associated", "with", "this", "node", "and", "its", "descendants", "excluding", "any", "duplicates", "." ]
6c58e356af3fbe7b23557643ba27e46eaef9d4e3
https://github.com/maceoutliner/django-fiction-outlines/blob/6c58e356af3fbe7b23557643ba27e46eaef9d4e3/fiction_outlines/models.py#L927-L936
241,688
maceoutliner/django-fiction-outlines
fiction_outlines/models.py
StoryElementNode.move
def move(self, target, pos=None): ''' An override of the treebeard api in order to send a signal in advance. ''' if self.outline != target.outline: raise IntegrityError('Elements must be from the same outline!') tree_manipulation.send( sender=self.__class_...
python
def move(self, target, pos=None): ''' An override of the treebeard api in order to send a signal in advance. ''' if self.outline != target.outline: raise IntegrityError('Elements must be from the same outline!') tree_manipulation.send( sender=self.__class_...
[ "def", "move", "(", "self", ",", "target", ",", "pos", "=", "None", ")", ":", "if", "self", ".", "outline", "!=", "target", ".", "outline", ":", "raise", "IntegrityError", "(", "'Elements must be from the same outline!'", ")", "tree_manipulation", ".", "send",...
An override of the treebeard api in order to send a signal in advance.
[ "An", "override", "of", "the", "treebeard", "api", "in", "order", "to", "send", "a", "signal", "in", "advance", "." ]
6c58e356af3fbe7b23557643ba27e46eaef9d4e3
https://github.com/maceoutliner/django-fiction-outlines/blob/6c58e356af3fbe7b23557643ba27e46eaef9d4e3/fiction_outlines/models.py#L938-L952
241,689
stefankoegl/bitlove-python
bitlove.py
BitloveClient.get_by_enclosures
def get_by_enclosures(self, enclosure_urls): """ Get bitlove data for a list of enclosure URLs """ # prepare URLs enclosure_urls = map(str.strip, enclosure_urls) enclosure_urls = filter(None, enclosure_urls) return BitloveResponse(self.opener, enclosure_urls)
python
def get_by_enclosures(self, enclosure_urls): """ Get bitlove data for a list of enclosure URLs """ # prepare URLs enclosure_urls = map(str.strip, enclosure_urls) enclosure_urls = filter(None, enclosure_urls) return BitloveResponse(self.opener, enclosure_urls)
[ "def", "get_by_enclosures", "(", "self", ",", "enclosure_urls", ")", ":", "# prepare URLs", "enclosure_urls", "=", "map", "(", "str", ".", "strip", ",", "enclosure_urls", ")", "enclosure_urls", "=", "filter", "(", "None", ",", "enclosure_urls", ")", "return", ...
Get bitlove data for a list of enclosure URLs
[ "Get", "bitlove", "data", "for", "a", "list", "of", "enclosure", "URLs" ]
4ca4a3fe8d115782876f9e7ee5deac66119cc410
https://github.com/stefankoegl/bitlove-python/blob/4ca4a3fe8d115782876f9e7ee5deac66119cc410/bitlove.py#L71-L78
241,690
stefankoegl/bitlove-python
bitlove.py
BitloveResponse.get
def get(self, url): """ Get the response for the given enclosure URL """ self._query() return Enclosure(self._resp.get(url), url)
python
def get(self, url): """ Get the response for the given enclosure URL """ self._query() return Enclosure(self._resp.get(url), url)
[ "def", "get", "(", "self", ",", "url", ")", ":", "self", ".", "_query", "(", ")", "return", "Enclosure", "(", "self", ".", "_resp", ".", "get", "(", "url", ")", ",", "url", ")" ]
Get the response for the given enclosure URL
[ "Get", "the", "response", "for", "the", "given", "enclosure", "URL" ]
4ca4a3fe8d115782876f9e7ee5deac66119cc410
https://github.com/stefankoegl/bitlove-python/blob/4ca4a3fe8d115782876f9e7ee5deac66119cc410/bitlove.py#L90-L93
241,691
stefankoegl/bitlove-python
bitlove.py
BitloveResponse._query
def _query(self): """ perform a request to the API, only when necessary """ if not self.urls: self._resp = {} elif self._resp is None: params = [ ('url', url) for url in self.urls] query = urllib.urlencode(params) # query API r = sel...
python
def _query(self): """ perform a request to the API, only when necessary """ if not self.urls: self._resp = {} elif self._resp is None: params = [ ('url', url) for url in self.urls] query = urllib.urlencode(params) # query API r = sel...
[ "def", "_query", "(", "self", ")", ":", "if", "not", "self", ".", "urls", ":", "self", ".", "_resp", "=", "{", "}", "elif", "self", ".", "_resp", "is", "None", ":", "params", "=", "[", "(", "'url'", ",", "url", ")", "for", "url", "in", "self", ...
perform a request to the API, only when necessary
[ "perform", "a", "request", "to", "the", "API", "only", "when", "necessary" ]
4ca4a3fe8d115782876f9e7ee5deac66119cc410
https://github.com/stefankoegl/bitlove-python/blob/4ca4a3fe8d115782876f9e7ee5deac66119cc410/bitlove.py#L102-L114
241,692
iamFIREcracker/aadbook
aadbook/aadbook.py
_build_parser
def _build_parser(): """ Return a command-line arguments parser. """ parser = argparse.ArgumentParser(description='Search you Azure AD contacts from mutt or the command-line.') parser.add_argument('-c', '--config', help='Specify alternative configuration file.', metavar="FILE") parser.add_argume...
python
def _build_parser(): """ Return a command-line arguments parser. """ parser = argparse.ArgumentParser(description='Search you Azure AD contacts from mutt or the command-line.') parser.add_argument('-c', '--config', help='Specify alternative configuration file.', metavar="FILE") parser.add_argume...
[ "def", "_build_parser", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", "description", "=", "'Search you Azure AD contacts from mutt or the command-line.'", ")", "parser", ".", "add_argument", "(", "'-c'", ",", "'--config'", ",", "help", "=", "...
Return a command-line arguments parser.
[ "Return", "a", "command", "-", "line", "arguments", "parser", "." ]
d191e9d36a2309449ab91c1728eaf5901b7ef91c
https://github.com/iamFIREcracker/aadbook/blob/d191e9d36a2309449ab91c1728eaf5901b7ef91c/aadbook/aadbook.py#L40-L75
241,693
krinj/k-util
setup.py
find_packages_under
def find_packages_under(path): """ Recursive list all of the packages under a specific package.""" all_packages = setuptools.find_packages() packages = [] for package in all_packages: package_split = package.split(".") if package_split[0] == path: packages.append(package) ...
python
def find_packages_under(path): """ Recursive list all of the packages under a specific package.""" all_packages = setuptools.find_packages() packages = [] for package in all_packages: package_split = package.split(".") if package_split[0] == path: packages.append(package) ...
[ "def", "find_packages_under", "(", "path", ")", ":", "all_packages", "=", "setuptools", ".", "find_packages", "(", ")", "packages", "=", "[", "]", "for", "package", "in", "all_packages", ":", "package_split", "=", "package", ".", "split", "(", "\".\"", ")", ...
Recursive list all of the packages under a specific package.
[ "Recursive", "list", "all", "of", "the", "packages", "under", "a", "specific", "package", "." ]
b118826b1d6f49ca4e1ca7327d5b171db332ac23
https://github.com/krinj/k-util/blob/b118826b1d6f49ca4e1ca7327d5b171db332ac23/setup.py#L25-L33
241,694
krinj/k-util
setup.py
copy_version_to_package
def copy_version_to_package(path): """ Copy the single source of truth version number into the package as well. """ init_file = os.path.join(path, "__init__.py") with open(init_file, "r") as original_file: lines = original_file.readlines() with open(init_file, "w") as new_file: for line...
python
def copy_version_to_package(path): """ Copy the single source of truth version number into the package as well. """ init_file = os.path.join(path, "__init__.py") with open(init_file, "r") as original_file: lines = original_file.readlines() with open(init_file, "w") as new_file: for line...
[ "def", "copy_version_to_package", "(", "path", ")", ":", "init_file", "=", "os", ".", "path", ".", "join", "(", "path", ",", "\"__init__.py\"", ")", "with", "open", "(", "init_file", ",", "\"r\"", ")", "as", "original_file", ":", "lines", "=", "original_fi...
Copy the single source of truth version number into the package as well.
[ "Copy", "the", "single", "source", "of", "truth", "version", "number", "into", "the", "package", "as", "well", "." ]
b118826b1d6f49ca4e1ca7327d5b171db332ac23
https://github.com/krinj/k-util/blob/b118826b1d6f49ca4e1ca7327d5b171db332ac23/setup.py#L36-L47
241,695
privacee/freelan-configurator
freelan_configurator/freelan_cfg.py
FreelanCFG.validate
def validate(self): """Validation of configuration to check for required values""" if not self.server.enabled: if self.security.signature_certificate_file is self.security.defaults['signature_certificate_file']: print("ISSUE: If you are not configuring a server, you need to...
python
def validate(self): """Validation of configuration to check for required values""" if not self.server.enabled: if self.security.signature_certificate_file is self.security.defaults['signature_certificate_file']: print("ISSUE: If you are not configuring a server, you need to...
[ "def", "validate", "(", "self", ")", ":", "if", "not", "self", ".", "server", ".", "enabled", ":", "if", "self", ".", "security", ".", "signature_certificate_file", "is", "self", ".", "security", ".", "defaults", "[", "'signature_certificate_file'", "]", ":"...
Validation of configuration to check for required values
[ "Validation", "of", "configuration", "to", "check", "for", "required", "values" ]
7c070f8958454792f870ef0d195a7f5da36edb5a
https://github.com/privacee/freelan-configurator/blob/7c070f8958454792f870ef0d195a7f5da36edb5a/freelan_configurator/freelan_cfg.py#L192-L247
241,696
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/admin.py
register_admin
def register_admin(app, admin): """Called on app initialization to register administration interface.""" category = 'Knowledge' admin.category_icon_classes[category] = "fa fa-mortar-board" admin.add_view( KnowledgeAdmin(app, KnwKB, db.session, name='Knowledge Base', catego...
python
def register_admin(app, admin): """Called on app initialization to register administration interface.""" category = 'Knowledge' admin.category_icon_classes[category] = "fa fa-mortar-board" admin.add_view( KnowledgeAdmin(app, KnwKB, db.session, name='Knowledge Base', catego...
[ "def", "register_admin", "(", "app", ",", "admin", ")", ":", "category", "=", "'Knowledge'", "admin", ".", "category_icon_classes", "[", "category", "]", "=", "\"fa fa-mortar-board\"", "admin", ".", "add_view", "(", "KnowledgeAdmin", "(", "app", ",", "KnwKB", ...
Called on app initialization to register administration interface.
[ "Called", "on", "app", "initialization", "to", "register", "administration", "interface", "." ]
b31722dc14243ca8f626f8b3bce9718d0119de55
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/admin.py#L188-L201
241,697
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/admin.py
KnowledgeAdmin.after_model_change
def after_model_change(self, form, model, is_created): """Save model.""" super(KnowledgeAdmin, self).after_model_change(form, model, is_created) from invenio_collections.models import Collection if form.kbtype.data == KnwKB.KNWKB_TYPES['dynamic']: id_collection = form.id_col...
python
def after_model_change(self, form, model, is_created): """Save model.""" super(KnowledgeAdmin, self).after_model_change(form, model, is_created) from invenio_collections.models import Collection if form.kbtype.data == KnwKB.KNWKB_TYPES['dynamic']: id_collection = form.id_col...
[ "def", "after_model_change", "(", "self", ",", "form", ",", "model", ",", "is_created", ")", ":", "super", "(", "KnowledgeAdmin", ",", "self", ")", ".", "after_model_change", "(", "form", ",", "model", ",", "is_created", ")", "from", "invenio_collections", "...
Save model.
[ "Save", "model", "." ]
b31722dc14243ca8f626f8b3bce9718d0119de55
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/admin.py#L104-L125
241,698
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/admin.py
KnowledgeAdmin.edit_form
def edit_form(self, obj=None): """Edit form.""" kbtype = request.args['kbtype'] if 'kbtype' in request.args else 'w' if kbtype == KnwKB.KNWKB_TYPES['written_as']: self.form = WrittenAsKnowledgeForm elif kbtype == KnwKB.KNWKB_TYPES['dynamic']: self.form = DynamicK...
python
def edit_form(self, obj=None): """Edit form.""" kbtype = request.args['kbtype'] if 'kbtype' in request.args else 'w' if kbtype == KnwKB.KNWKB_TYPES['written_as']: self.form = WrittenAsKnowledgeForm elif kbtype == KnwKB.KNWKB_TYPES['dynamic']: self.form = DynamicK...
[ "def", "edit_form", "(", "self", ",", "obj", "=", "None", ")", ":", "kbtype", "=", "request", ".", "args", "[", "'kbtype'", "]", "if", "'kbtype'", "in", "request", ".", "args", "else", "'w'", "if", "kbtype", "==", "KnwKB", ".", "KNWKB_TYPES", "[", "'...
Edit form.
[ "Edit", "form", "." ]
b31722dc14243ca8f626f8b3bce9718d0119de55
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/admin.py#L127-L158
241,699
inveniosoftware-attic/invenio-knowledge
invenio_knowledge/admin.py
KnowledgeAdmin.create_form
def create_form(self, obj=None): """Create form.""" kbtype = request.args['kbtype'] if 'kbtype' in request.args else 'w' if kbtype == KnwKB.KNWKB_TYPES['written_as']: self.form = WrittenAsKnowledgeForm elif kbtype == KnwKB.KNWKB_TYPES['dynamic']: self.form = Dyna...
python
def create_form(self, obj=None): """Create form.""" kbtype = request.args['kbtype'] if 'kbtype' in request.args else 'w' if kbtype == KnwKB.KNWKB_TYPES['written_as']: self.form = WrittenAsKnowledgeForm elif kbtype == KnwKB.KNWKB_TYPES['dynamic']: self.form = Dyna...
[ "def", "create_form", "(", "self", ",", "obj", "=", "None", ")", ":", "kbtype", "=", "request", ".", "args", "[", "'kbtype'", "]", "if", "'kbtype'", "in", "request", ".", "args", "else", "'w'", "if", "kbtype", "==", "KnwKB", ".", "KNWKB_TYPES", "[", ...
Create form.
[ "Create", "form", "." ]
b31722dc14243ca8f626f8b3bce9718d0119de55
https://github.com/inveniosoftware-attic/invenio-knowledge/blob/b31722dc14243ca8f626f8b3bce9718d0119de55/invenio_knowledge/admin.py#L160-L174