repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
walkr/nanoservice
nanoservice/core.py
Endpoint.initialize
def initialize(self, timeouts): """ Bind or connect the nanomsg socket to some address """ # Bind or connect to address if self.bind is True: self.socket.bind(self.address) else: self.socket.connect(self.address) # Set send and recv timeouts self...
python
def initialize(self, timeouts): """ Bind or connect the nanomsg socket to some address """ # Bind or connect to address if self.bind is True: self.socket.bind(self.address) else: self.socket.connect(self.address) # Set send and recv timeouts self...
[ "def", "initialize", "(", "self", ",", "timeouts", ")", ":", "# Bind or connect to address", "if", "self", ".", "bind", "is", "True", ":", "self", ".", "socket", ".", "bind", "(", "self", ".", "address", ")", "else", ":", "self", ".", "socket", ".", "c...
Bind or connect the nanomsg socket to some address
[ "Bind", "or", "connect", "the", "nanomsg", "socket", "to", "some", "address" ]
e2098986b1baa5f283167ae487d14f3c6c21961a
https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/nanoservice/core.py#L67-L77
train
walkr/nanoservice
nanoservice/core.py
Endpoint._set_timeouts
def _set_timeouts(self, timeouts): """ Set socket timeouts for send and receive respectively """ (send_timeout, recv_timeout) = (None, None) try: (send_timeout, recv_timeout) = timeouts except TypeError: raise EndpointError( '`timeouts` must be a...
python
def _set_timeouts(self, timeouts): """ Set socket timeouts for send and receive respectively """ (send_timeout, recv_timeout) = (None, None) try: (send_timeout, recv_timeout) = timeouts except TypeError: raise EndpointError( '`timeouts` must be a...
[ "def", "_set_timeouts", "(", "self", ",", "timeouts", ")", ":", "(", "send_timeout", ",", "recv_timeout", ")", "=", "(", "None", ",", "None", ")", "try", ":", "(", "send_timeout", ",", "recv_timeout", ")", "=", "timeouts", "except", "TypeError", ":", "ra...
Set socket timeouts for send and receive respectively
[ "Set", "socket", "timeouts", "for", "send", "and", "receive", "respectively" ]
e2098986b1baa5f283167ae487d14f3c6c21961a
https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/nanoservice/core.py#L79-L97
train
walkr/nanoservice
nanoservice/core.py
Endpoint.send
def send(self, payload): """ Encode and sign (optional) the send through socket """ payload = self.encode(payload) payload = self.sign(payload) self.socket.send(payload)
python
def send(self, payload): """ Encode and sign (optional) the send through socket """ payload = self.encode(payload) payload = self.sign(payload) self.socket.send(payload)
[ "def", "send", "(", "self", ",", "payload", ")", ":", "payload", "=", "self", ".", "encode", "(", "payload", ")", "payload", "=", "self", ".", "sign", "(", "payload", ")", "self", ".", "socket", ".", "send", "(", "payload", ")" ]
Encode and sign (optional) the send through socket
[ "Encode", "and", "sign", "(", "optional", ")", "the", "send", "through", "socket" ]
e2098986b1baa5f283167ae487d14f3c6c21961a
https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/nanoservice/core.py#L99-L103
train
walkr/nanoservice
nanoservice/core.py
Endpoint.receive
def receive(self, decode=True): """ Receive from socket, authenticate and decode payload """ payload = self.socket.recv() payload = self.verify(payload) if decode: payload = self.decode(payload) return payload
python
def receive(self, decode=True): """ Receive from socket, authenticate and decode payload """ payload = self.socket.recv() payload = self.verify(payload) if decode: payload = self.decode(payload) return payload
[ "def", "receive", "(", "self", ",", "decode", "=", "True", ")", ":", "payload", "=", "self", ".", "socket", ".", "recv", "(", ")", "payload", "=", "self", ".", "verify", "(", "payload", ")", "if", "decode", ":", "payload", "=", "self", ".", "decode...
Receive from socket, authenticate and decode payload
[ "Receive", "from", "socket", "authenticate", "and", "decode", "payload" ]
e2098986b1baa5f283167ae487d14f3c6c21961a
https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/nanoservice/core.py#L105-L111
train
walkr/nanoservice
nanoservice/core.py
Endpoint.sign
def sign(self, payload): """ Sign payload using the supplied authenticator """ if self.authenticator: return self.authenticator.signed(payload) return payload
python
def sign(self, payload): """ Sign payload using the supplied authenticator """ if self.authenticator: return self.authenticator.signed(payload) return payload
[ "def", "sign", "(", "self", ",", "payload", ")", ":", "if", "self", ".", "authenticator", ":", "return", "self", ".", "authenticator", ".", "signed", "(", "payload", ")", "return", "payload" ]
Sign payload using the supplied authenticator
[ "Sign", "payload", "using", "the", "supplied", "authenticator" ]
e2098986b1baa5f283167ae487d14f3c6c21961a
https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/nanoservice/core.py#L113-L117
train
walkr/nanoservice
nanoservice/core.py
Endpoint.verify
def verify(self, payload): """ Verify payload authenticity via the supplied authenticator """ if not self.authenticator: return payload try: self.authenticator.auth(payload) return self.authenticator.unsigned(payload) except AuthenticatorInvalidSignatu...
python
def verify(self, payload): """ Verify payload authenticity via the supplied authenticator """ if not self.authenticator: return payload try: self.authenticator.auth(payload) return self.authenticator.unsigned(payload) except AuthenticatorInvalidSignatu...
[ "def", "verify", "(", "self", ",", "payload", ")", ":", "if", "not", "self", ".", "authenticator", ":", "return", "payload", "try", ":", "self", ".", "authenticator", ".", "auth", "(", "payload", ")", "return", "self", ".", "authenticator", ".", "unsigne...
Verify payload authenticity via the supplied authenticator
[ "Verify", "payload", "authenticity", "via", "the", "supplied", "authenticator" ]
e2098986b1baa5f283167ae487d14f3c6c21961a
https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/nanoservice/core.py#L119-L129
train
walkr/nanoservice
nanoservice/core.py
Endpoint.decode
def decode(self, payload): """ Decode payload """ try: return self.encoder.decode(payload) except Exception as exception: raise DecodeError(str(exception))
python
def decode(self, payload): """ Decode payload """ try: return self.encoder.decode(payload) except Exception as exception: raise DecodeError(str(exception))
[ "def", "decode", "(", "self", ",", "payload", ")", ":", "try", ":", "return", "self", ".", "encoder", ".", "decode", "(", "payload", ")", "except", "Exception", "as", "exception", ":", "raise", "DecodeError", "(", "str", "(", "exception", ")", ")" ]
Decode payload
[ "Decode", "payload" ]
e2098986b1baa5f283167ae487d14f3c6c21961a
https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/nanoservice/core.py#L131-L136
train
walkr/nanoservice
nanoservice/core.py
Endpoint.encode
def encode(self, payload): """ Encode payload """ try: return self.encoder.encode(payload) except Exception as exception: raise EncodeError(str(exception))
python
def encode(self, payload): """ Encode payload """ try: return self.encoder.encode(payload) except Exception as exception: raise EncodeError(str(exception))
[ "def", "encode", "(", "self", ",", "payload", ")", ":", "try", ":", "return", "self", ".", "encoder", ".", "encode", "(", "payload", ")", "except", "Exception", "as", "exception", ":", "raise", "EncodeError", "(", "str", "(", "exception", ")", ")" ]
Encode payload
[ "Encode", "payload" ]
e2098986b1baa5f283167ae487d14f3c6c21961a
https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/nanoservice/core.py#L138-L143
train
walkr/nanoservice
nanoservice/core.py
Process.start
def start(self): """ Start and listen for calls """ if threading.current_thread().name == 'MainThread': signal.signal(signal.SIGINT, self.stop) logging.info('Started on {}'.format(self.address)) while True: self.process()
python
def start(self): """ Start and listen for calls """ if threading.current_thread().name == 'MainThread': signal.signal(signal.SIGINT, self.stop) logging.info('Started on {}'.format(self.address)) while True: self.process()
[ "def", "start", "(", "self", ")", ":", "if", "threading", ".", "current_thread", "(", ")", ".", "name", "==", "'MainThread'", ":", "signal", ".", "signal", "(", "signal", ".", "SIGINT", ",", "self", ".", "stop", ")", "logging", ".", "info", "(", "'St...
Start and listen for calls
[ "Start", "and", "listen", "for", "calls" ]
e2098986b1baa5f283167ae487d14f3c6c21961a
https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/nanoservice/core.py#L149-L158
train
walkr/nanoservice
nanoservice/core.py
Process.stop
def stop(self, dummy_signum=None, dummy_frame=None): """ Shutdown process (this method is also a signal handler) """ logging.info('Shutting down ...') self.socket.close() sys.exit(0)
python
def stop(self, dummy_signum=None, dummy_frame=None): """ Shutdown process (this method is also a signal handler) """ logging.info('Shutting down ...') self.socket.close() sys.exit(0)
[ "def", "stop", "(", "self", ",", "dummy_signum", "=", "None", ",", "dummy_frame", "=", "None", ")", ":", "logging", ".", "info", "(", "'Shutting down ...'", ")", "self", ".", "socket", ".", "close", "(", ")", "sys", ".", "exit", "(", "0", ")" ]
Shutdown process (this method is also a signal handler)
[ "Shutdown", "process", "(", "this", "method", "is", "also", "a", "signal", "handler", ")" ]
e2098986b1baa5f283167ae487d14f3c6c21961a
https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/nanoservice/core.py#L160-L164
train
RockFeng0/rtsf
rtsf/p_report.py
HtmlReporter.get_summary
def get_summary(list_all=[], **kwargs): ''' summarize the report data @param list_all: a list which save the report data @param kwargs: such as show_all: True/False report show all status cases proj_name: project name home_pag...
python
def get_summary(list_all=[], **kwargs): ''' summarize the report data @param list_all: a list which save the report data @param kwargs: such as show_all: True/False report show all status cases proj_name: project name home_pag...
[ "def", "get_summary", "(", "list_all", "=", "[", "]", ",", "*", "*", "kwargs", ")", ":", "all_summary", "=", "[", "]", "for", "module", "in", "list_all", ":", "summary", "=", "{", "\"module_name\"", ":", "module", "[", "'Name'", "]", ",", "\"show_all\"...
summarize the report data @param list_all: a list which save the report data @param kwargs: such as show_all: True/False report show all status cases proj_name: project name home_page: home page url
[ "summarize", "the", "report", "data" ]
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_report.py#L134-L193
train
RockFeng0/rtsf
rtsf/p_report.py
HtmlReporter.add_report_data
def add_report_data(list_all=[], module_name="TestModule", **kwargs): ''' add report data to a list @param list_all: a list which save the report data @param module_name: test set name or test module name @param kwargs: such as case_name: testcase name ...
python
def add_report_data(list_all=[], module_name="TestModule", **kwargs): ''' add report data to a list @param list_all: a list which save the report data @param module_name: test set name or test module name @param kwargs: such as case_name: testcase name ...
[ "def", "add_report_data", "(", "list_all", "=", "[", "]", ",", "module_name", "=", "\"TestModule\"", ",", "*", "*", "kwargs", ")", ":", "start_at", "=", "kwargs", ".", "get", "(", "\"start_at\"", ")", "case_name", "=", "kwargs", ".", "get", "(", "\"case_...
add report data to a list @param list_all: a list which save the report data @param module_name: test set name or test module name @param kwargs: such as case_name: testcase name status: test result, Pass or Fail resp_teste...
[ "add", "report", "data", "to", "a", "list" ]
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_report.py#L196-L241
train
walkr/nanoservice
nanoservice/pubsub.py
Subscriber.parse
def parse(self, subscription): """ Fetch the function registered for a certain subscription """ for name in self.methods: tag = bytes(name.encode('utf-8')) if subscription.startswith(tag): fun = self.methods.get(name) message = subscription[len(ta...
python
def parse(self, subscription): """ Fetch the function registered for a certain subscription """ for name in self.methods: tag = bytes(name.encode('utf-8')) if subscription.startswith(tag): fun = self.methods.get(name) message = subscription[len(ta...
[ "def", "parse", "(", "self", ",", "subscription", ")", ":", "for", "name", "in", "self", ".", "methods", ":", "tag", "=", "bytes", "(", "name", ".", "encode", "(", "'utf-8'", ")", ")", "if", "subscription", ".", "startswith", "(", "tag", ")", ":", ...
Fetch the function registered for a certain subscription
[ "Fetch", "the", "function", "registered", "for", "a", "certain", "subscription" ]
e2098986b1baa5f283167ae487d14f3c6c21961a
https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/nanoservice/pubsub.py#L57-L66
train
walkr/nanoservice
nanoservice/pubsub.py
Subscriber.subscribe
def subscribe(self, tag, fun, description=None): """ Subscribe to something and register a function """ self.methods[tag] = fun self.descriptions[tag] = description self.socket.set_string_option(nanomsg.SUB, nanomsg.SUB_SUBSCRIBE, tag)
python
def subscribe(self, tag, fun, description=None): """ Subscribe to something and register a function """ self.methods[tag] = fun self.descriptions[tag] = description self.socket.set_string_option(nanomsg.SUB, nanomsg.SUB_SUBSCRIBE, tag)
[ "def", "subscribe", "(", "self", ",", "tag", ",", "fun", ",", "description", "=", "None", ")", ":", "self", ".", "methods", "[", "tag", "]", "=", "fun", "self", ".", "descriptions", "[", "tag", "]", "=", "description", "self", ".", "socket", ".", "...
Subscribe to something and register a function
[ "Subscribe", "to", "something", "and", "register", "a", "function" ]
e2098986b1baa5f283167ae487d14f3c6c21961a
https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/nanoservice/pubsub.py#L72-L76
train
walkr/nanoservice
nanoservice/pubsub.py
Subscriber.process
def process(self): """ Receive a subscription from the socket and process it """ subscription = None result = None try: subscription = self.socket.recv() except AuthenticateError as exception: logging.error( 'Subscriber error while authe...
python
def process(self): """ Receive a subscription from the socket and process it """ subscription = None result = None try: subscription = self.socket.recv() except AuthenticateError as exception: logging.error( 'Subscriber error while authe...
[ "def", "process", "(", "self", ")", ":", "subscription", "=", "None", "result", "=", "None", "try", ":", "subscription", "=", "self", ".", "socket", ".", "recv", "(", ")", "except", "AuthenticateError", "as", "exception", ":", "logging", ".", "error", "(...
Receive a subscription from the socket and process it
[ "Receive", "a", "subscription", "from", "the", "socket", "and", "process", "it" ]
e2098986b1baa5f283167ae487d14f3c6c21961a
https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/nanoservice/pubsub.py#L80-L124
train
walkr/nanoservice
nanoservice/pubsub.py
Publisher.build_payload
def build_payload(self, tag, message): """ Encode, sign payload(optional) and attach subscription tag """ message = self.encode(message) message = self.sign(message) payload = bytes(tag.encode('utf-8')) + message return payload
python
def build_payload(self, tag, message): """ Encode, sign payload(optional) and attach subscription tag """ message = self.encode(message) message = self.sign(message) payload = bytes(tag.encode('utf-8')) + message return payload
[ "def", "build_payload", "(", "self", ",", "tag", ",", "message", ")", ":", "message", "=", "self", ".", "encode", "(", "message", ")", "message", "=", "self", ".", "sign", "(", "message", ")", "payload", "=", "bytes", "(", "tag", ".", "encode", "(", ...
Encode, sign payload(optional) and attach subscription tag
[ "Encode", "sign", "payload", "(", "optional", ")", "and", "attach", "subscription", "tag" ]
e2098986b1baa5f283167ae487d14f3c6c21961a
https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/nanoservice/pubsub.py#L142-L147
train
walkr/nanoservice
nanoservice/pubsub.py
Publisher.publish
def publish(self, tag, message): """ Publish a message down the socket """ payload = self.build_payload(tag, message) self.socket.send(payload)
python
def publish(self, tag, message): """ Publish a message down the socket """ payload = self.build_payload(tag, message) self.socket.send(payload)
[ "def", "publish", "(", "self", ",", "tag", ",", "message", ")", ":", "payload", "=", "self", ".", "build_payload", "(", "tag", ",", "message", ")", "self", ".", "socket", ".", "send", "(", "payload", ")" ]
Publish a message down the socket
[ "Publish", "a", "message", "down", "the", "socket" ]
e2098986b1baa5f283167ae487d14f3c6c21961a
https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/nanoservice/pubsub.py#L149-L152
train
walkr/nanoservice
benchmarks/bench_pub_sub_auth.py
start_service
def start_service(addr, n, authenticator): """ Start a service """ s = Subscriber(addr, authenticator=authenticator) def do_something(line): pass s.subscribe('test', do_something) started = time.time() for _ in range(n): s.process() s.socket.close() duration = time.ti...
python
def start_service(addr, n, authenticator): """ Start a service """ s = Subscriber(addr, authenticator=authenticator) def do_something(line): pass s.subscribe('test', do_something) started = time.time() for _ in range(n): s.process() s.socket.close() duration = time.ti...
[ "def", "start_service", "(", "addr", ",", "n", ",", "authenticator", ")", ":", "s", "=", "Subscriber", "(", "addr", ",", "authenticator", "=", "authenticator", ")", "def", "do_something", "(", "line", ")", ":", "pass", "s", ".", "subscribe", "(", "'test'...
Start a service
[ "Start", "a", "service" ]
e2098986b1baa5f283167ae487d14f3c6c21961a
https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/benchmarks/bench_pub_sub_auth.py#L13-L31
train
walkr/nanoservice
benchmarks/bench_pub_sub_auth.py
bench
def bench(client, n): """ Benchmark n requests """ items = list(range(n)) # Time client publish operations # ------------------------------ started = time.time() for i in items: client.publish('test', i) duration = time.time() - started print('Publisher client stats:') util...
python
def bench(client, n): """ Benchmark n requests """ items = list(range(n)) # Time client publish operations # ------------------------------ started = time.time() for i in items: client.publish('test', i) duration = time.time() - started print('Publisher client stats:') util...
[ "def", "bench", "(", "client", ",", "n", ")", ":", "items", "=", "list", "(", "range", "(", "n", ")", ")", "# Time client publish operations", "# ------------------------------", "started", "=", "time", ".", "time", "(", ")", "for", "i", "in", "items", ":"...
Benchmark n requests
[ "Benchmark", "n", "requests" ]
e2098986b1baa5f283167ae487d14f3c6c21961a
https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/benchmarks/bench_pub_sub_auth.py#L34-L46
train
stevearc/pyramid_webpack
pyramid_webpack/__init__.py
get_webpack
def get_webpack(request, name='DEFAULT'): """ Get the Webpack object for a given webpack config. Called at most once per request per config name. """ if not hasattr(request, '_webpack_map'): request._webpack_map = {} wp = request._webpack_map.get(name) if wp is None: wp = re...
python
def get_webpack(request, name='DEFAULT'): """ Get the Webpack object for a given webpack config. Called at most once per request per config name. """ if not hasattr(request, '_webpack_map'): request._webpack_map = {} wp = request._webpack_map.get(name) if wp is None: wp = re...
[ "def", "get_webpack", "(", "request", ",", "name", "=", "'DEFAULT'", ")", ":", "if", "not", "hasattr", "(", "request", ",", "'_webpack_map'", ")", ":", "request", ".", "_webpack_map", "=", "{", "}", "wp", "=", "request", ".", "_webpack_map", ".", "get", ...
Get the Webpack object for a given webpack config. Called at most once per request per config name.
[ "Get", "the", "Webpack", "object", "for", "a", "given", "webpack", "config", "." ]
4fcad26271fd6e8c270e19c7943240fea6d8c484
https://github.com/stevearc/pyramid_webpack/blob/4fcad26271fd6e8c270e19c7943240fea6d8c484/pyramid_webpack/__init__.py#L212-L223
train
stevearc/pyramid_webpack
pyramid_webpack/__init__.py
includeme
def includeme(config): """ Add pyramid_webpack methods and config to the app """ settings = config.registry.settings root_package_name = config.root_package.__name__ config.registry.webpack = { 'DEFAULT': WebpackState(settings, root_package_name) } for extra_config in aslist(settings.get...
python
def includeme(config): """ Add pyramid_webpack methods and config to the app """ settings = config.registry.settings root_package_name = config.root_package.__name__ config.registry.webpack = { 'DEFAULT': WebpackState(settings, root_package_name) } for extra_config in aslist(settings.get...
[ "def", "includeme", "(", "config", ")", ":", "settings", "=", "config", ".", "registry", ".", "settings", "root_package_name", "=", "config", ".", "root_package", ".", "__name__", "config", ".", "registry", ".", "webpack", "=", "{", "'DEFAULT'", ":", "Webpac...
Add pyramid_webpack methods and config to the app
[ "Add", "pyramid_webpack", "methods", "and", "config", "to", "the", "app" ]
4fcad26271fd6e8c270e19c7943240fea6d8c484
https://github.com/stevearc/pyramid_webpack/blob/4fcad26271fd6e8c270e19c7943240fea6d8c484/pyramid_webpack/__init__.py#L226-L244
train
stevearc/pyramid_webpack
pyramid_webpack/__init__.py
WebpackState._get_setting
def _get_setting(self, setting, default=None, name=None, inherit=True): """ Helper function to fetch settings, inheriting from the base """ if name is None: name = self.name if name == 'DEFAULT': return self._settings.get('webpack.{0}'.format(setting), default) el...
python
def _get_setting(self, setting, default=None, name=None, inherit=True): """ Helper function to fetch settings, inheriting from the base """ if name is None: name = self.name if name == 'DEFAULT': return self._settings.get('webpack.{0}'.format(setting), default) el...
[ "def", "_get_setting", "(", "self", ",", "setting", ",", "default", "=", "None", ",", "name", "=", "None", ",", "inherit", "=", "True", ")", ":", "if", "name", "is", "None", ":", "name", "=", "self", ".", "name", "if", "name", "==", "'DEFAULT'", ":...
Helper function to fetch settings, inheriting from the base
[ "Helper", "function", "to", "fetch", "settings", "inheriting", "from", "the", "base" ]
4fcad26271fd6e8c270e19c7943240fea6d8c484
https://github.com/stevearc/pyramid_webpack/blob/4fcad26271fd6e8c270e19c7943240fea6d8c484/pyramid_webpack/__init__.py#L93-L108
train
stevearc/pyramid_webpack
pyramid_webpack/__init__.py
WebpackState.load_stats
def load_stats(self, cache=None, wait=None): """ Load and cache the webpack-stats file """ if cache is None: cache = not self.debug if wait is None: wait = self.debug if not cache or self._stats is None: self._stats = self._load_stats() sta...
python
def load_stats(self, cache=None, wait=None): """ Load and cache the webpack-stats file """ if cache is None: cache = not self.debug if wait is None: wait = self.debug if not cache or self._stats is None: self._stats = self._load_stats() sta...
[ "def", "load_stats", "(", "self", ",", "cache", "=", "None", ",", "wait", "=", "None", ")", ":", "if", "cache", "is", "None", ":", "cache", "=", "not", "self", ".", "debug", "if", "wait", "is", "None", ":", "wait", "=", "self", ".", "debug", "if"...
Load and cache the webpack-stats file
[ "Load", "and", "cache", "the", "webpack", "-", "stats", "file" ]
4fcad26271fd6e8c270e19c7943240fea6d8c484
https://github.com/stevearc/pyramid_webpack/blob/4fcad26271fd6e8c270e19c7943240fea6d8c484/pyramid_webpack/__init__.py#L110-L125
train
stevearc/pyramid_webpack
pyramid_webpack/__init__.py
WebpackState._load_stats
def _load_stats(self): """ Load the webpack-stats file """ for attempt in range(0, 3): try: with self.stats_file.open() as f: return json.load(f) except ValueError: # If we failed to parse the JSON, it's possible that the ...
python
def _load_stats(self): """ Load the webpack-stats file """ for attempt in range(0, 3): try: with self.stats_file.open() as f: return json.load(f) except ValueError: # If we failed to parse the JSON, it's possible that the ...
[ "def", "_load_stats", "(", "self", ")", ":", "for", "attempt", "in", "range", "(", "0", ",", "3", ")", ":", "try", ":", "with", "self", ".", "stats_file", ".", "open", "(", ")", "as", "f", ":", "return", "json", ".", "load", "(", "f", ")", "exc...
Load the webpack-stats file
[ "Load", "the", "webpack", "-", "stats", "file" ]
4fcad26271fd6e8c270e19c7943240fea6d8c484
https://github.com/stevearc/pyramid_webpack/blob/4fcad26271fd6e8c270e19c7943240fea6d8c484/pyramid_webpack/__init__.py#L127-L144
train
stevearc/pyramid_webpack
pyramid_webpack/__init__.py
Webpack._chunk_filter
def _chunk_filter(self, extensions): """ Create a filter from the extensions and ignore files """ if isinstance(extensions, six.string_types): extensions = extensions.split() def _filter(chunk): """ Exclusion filter """ name = chunk['name'] if ext...
python
def _chunk_filter(self, extensions): """ Create a filter from the extensions and ignore files """ if isinstance(extensions, six.string_types): extensions = extensions.split() def _filter(chunk): """ Exclusion filter """ name = chunk['name'] if ext...
[ "def", "_chunk_filter", "(", "self", ",", "extensions", ")", ":", "if", "isinstance", "(", "extensions", ",", "six", ".", "string_types", ")", ":", "extensions", "=", "extensions", ".", "split", "(", ")", "def", "_filter", "(", "chunk", ")", ":", "\"\"\"...
Create a filter from the extensions and ignore files
[ "Create", "a", "filter", "from", "the", "extensions", "and", "ignore", "files" ]
4fcad26271fd6e8c270e19c7943240fea6d8c484
https://github.com/stevearc/pyramid_webpack/blob/4fcad26271fd6e8c270e19c7943240fea6d8c484/pyramid_webpack/__init__.py#L163-L181
train
stevearc/pyramid_webpack
pyramid_webpack/__init__.py
Webpack._add_url
def _add_url(self, chunk): """ Add a 'url' property to a chunk and return it """ if 'url' in chunk: return chunk public_path = chunk.get('publicPath') if public_path: chunk['url'] = public_path else: fullpath = posixpath.join(self.state.static_...
python
def _add_url(self, chunk): """ Add a 'url' property to a chunk and return it """ if 'url' in chunk: return chunk public_path = chunk.get('publicPath') if public_path: chunk['url'] = public_path else: fullpath = posixpath.join(self.state.static_...
[ "def", "_add_url", "(", "self", ",", "chunk", ")", ":", "if", "'url'", "in", "chunk", ":", "return", "chunk", "public_path", "=", "chunk", ".", "get", "(", "'publicPath'", ")", "if", "public_path", ":", "chunk", "[", "'url'", "]", "=", "public_path", "...
Add a 'url' property to a chunk and return it
[ "Add", "a", "url", "property", "to", "a", "chunk", "and", "return", "it" ]
4fcad26271fd6e8c270e19c7943240fea6d8c484
https://github.com/stevearc/pyramid_webpack/blob/4fcad26271fd6e8c270e19c7943240fea6d8c484/pyramid_webpack/__init__.py#L183-L194
train
stevearc/pyramid_webpack
pyramid_webpack/__init__.py
Webpack.get_bundle
def get_bundle(self, bundle_name, extensions=None): """ Get all the chunks contained in a bundle """ if self.stats.get('status') == 'done': bundle = self.stats.get('chunks', {}).get(bundle_name, None) if bundle is None: raise KeyError('No such bundle {0!r}.'.forma...
python
def get_bundle(self, bundle_name, extensions=None): """ Get all the chunks contained in a bundle """ if self.stats.get('status') == 'done': bundle = self.stats.get('chunks', {}).get(bundle_name, None) if bundle is None: raise KeyError('No such bundle {0!r}.'.forma...
[ "def", "get_bundle", "(", "self", ",", "bundle_name", ",", "extensions", "=", "None", ")", ":", "if", "self", ".", "stats", ".", "get", "(", "'status'", ")", "==", "'done'", ":", "bundle", "=", "self", ".", "stats", ".", "get", "(", "'chunks'", ",", ...
Get all the chunks contained in a bundle
[ "Get", "all", "the", "chunks", "contained", "in", "a", "bundle" ]
4fcad26271fd6e8c270e19c7943240fea6d8c484
https://github.com/stevearc/pyramid_webpack/blob/4fcad26271fd6e8c270e19c7943240fea6d8c484/pyramid_webpack/__init__.py#L196-L209
train
VisTrails/tej
tej/submission.py
_unique_names
def _unique_names(): """Generates unique sequences of bytes. """ characters = ("abcdefghijklmnopqrstuvwxyz" "0123456789") characters = [characters[i:i + 1] for i in irange(len(characters))] rng = random.Random() while True: letters = [rng.choice(characters) for i in ira...
python
def _unique_names(): """Generates unique sequences of bytes. """ characters = ("abcdefghijklmnopqrstuvwxyz" "0123456789") characters = [characters[i:i + 1] for i in irange(len(characters))] rng = random.Random() while True: letters = [rng.choice(characters) for i in ira...
[ "def", "_unique_names", "(", ")", ":", "characters", "=", "(", "\"abcdefghijklmnopqrstuvwxyz\"", "\"0123456789\"", ")", "characters", "=", "[", "characters", "[", "i", ":", "i", "+", "1", "]", "for", "i", "in", "irange", "(", "len", "(", "characters", ")",...
Generates unique sequences of bytes.
[ "Generates", "unique", "sequences", "of", "bytes", "." ]
b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b
https://github.com/VisTrails/tej/blob/b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b/tej/submission.py#L31-L40
train
VisTrails/tej
tej/submission.py
escape_queue
def escape_queue(s): """Escapes the path to a queue, e.g. preserves ~ at the begining. """ if isinstance(s, PosixPath): s = unicode_(s) elif isinstance(s, bytes): s = s.decode('utf-8') if s.startswith('~/'): return '~/' + shell_escape(s[2:]) else: return shell_esc...
python
def escape_queue(s): """Escapes the path to a queue, e.g. preserves ~ at the begining. """ if isinstance(s, PosixPath): s = unicode_(s) elif isinstance(s, bytes): s = s.decode('utf-8') if s.startswith('~/'): return '~/' + shell_escape(s[2:]) else: return shell_esc...
[ "def", "escape_queue", "(", "s", ")", ":", "if", "isinstance", "(", "s", ",", "PosixPath", ")", ":", "s", "=", "unicode_", "(", "s", ")", "elif", "isinstance", "(", "s", ",", "bytes", ")", ":", "s", "=", "s", ".", "decode", "(", "'utf-8'", ")", ...
Escapes the path to a queue, e.g. preserves ~ at the begining.
[ "Escapes", "the", "path", "to", "a", "queue", "e", ".", "g", ".", "preserves", "~", "at", "the", "begining", "." ]
b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b
https://github.com/VisTrails/tej/blob/b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b/tej/submission.py#L52-L62
train
VisTrails/tej
tej/submission.py
parse_ssh_destination
def parse_ssh_destination(destination): """Parses the SSH destination argument. """ match = _re_ssh.match(destination) if not match: raise InvalidDestination("Invalid destination: %s" % destination) user, password, host, port = match.groups() info = {} if user: info['username...
python
def parse_ssh_destination(destination): """Parses the SSH destination argument. """ match = _re_ssh.match(destination) if not match: raise InvalidDestination("Invalid destination: %s" % destination) user, password, host, port = match.groups() info = {} if user: info['username...
[ "def", "parse_ssh_destination", "(", "destination", ")", ":", "match", "=", "_re_ssh", ".", "match", "(", "destination", ")", "if", "not", "match", ":", "raise", "InvalidDestination", "(", "\"Invalid destination: %s\"", "%", "destination", ")", "user", ",", "pas...
Parses the SSH destination argument.
[ "Parses", "the", "SSH", "destination", "argument", "." ]
b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b
https://github.com/VisTrails/tej/blob/b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b/tej/submission.py#L75-L93
train
VisTrails/tej
tej/submission.py
RemoteQueue._ssh_client
def _ssh_client(self): """Gets an SSH client to connect with. """ ssh = paramiko.SSHClient() ssh.load_system_host_keys() ssh.set_missing_host_key_policy(paramiko.RejectPolicy()) return ssh
python
def _ssh_client(self): """Gets an SSH client to connect with. """ ssh = paramiko.SSHClient() ssh.load_system_host_keys() ssh.set_missing_host_key_policy(paramiko.RejectPolicy()) return ssh
[ "def", "_ssh_client", "(", "self", ")", ":", "ssh", "=", "paramiko", ".", "SSHClient", "(", ")", "ssh", ".", "load_system_host_keys", "(", ")", "ssh", ".", "set_missing_host_key_policy", "(", "paramiko", ".", "RejectPolicy", "(", ")", ")", "return", "ssh" ]
Gets an SSH client to connect with.
[ "Gets", "an", "SSH", "client", "to", "connect", "with", "." ]
b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b
https://github.com/VisTrails/tej/blob/b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b/tej/submission.py#L201-L207
train
VisTrails/tej
tej/submission.py
RemoteQueue._connect
def _connect(self): """Connects via SSH. """ ssh = self._ssh_client() logger.debug("Connecting with %s", ', '.join('%s=%r' % (k, v if k != "password" else "***") for k, v in iteritems(self.destination))) ssh.connect(**self.desti...
python
def _connect(self): """Connects via SSH. """ ssh = self._ssh_client() logger.debug("Connecting with %s", ', '.join('%s=%r' % (k, v if k != "password" else "***") for k, v in iteritems(self.destination))) ssh.connect(**self.desti...
[ "def", "_connect", "(", "self", ")", ":", "ssh", "=", "self", ".", "_ssh_client", "(", ")", "logger", ".", "debug", "(", "\"Connecting with %s\"", ",", "', '", ".", "join", "(", "'%s=%r'", "%", "(", "k", ",", "v", "if", "k", "!=", "\"password\"", "el...
Connects via SSH.
[ "Connects", "via", "SSH", "." ]
b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b
https://github.com/VisTrails/tej/blob/b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b/tej/submission.py#L209-L218
train
VisTrails/tej
tej/submission.py
RemoteQueue.get_client
def get_client(self): """Gets the SSH client. This will check that the connection is still alive first, and reconnect if necessary. """ if self._ssh is None: self._connect() return self._ssh else: try: chan = self._ssh....
python
def get_client(self): """Gets the SSH client. This will check that the connection is still alive first, and reconnect if necessary. """ if self._ssh is None: self._connect() return self._ssh else: try: chan = self._ssh....
[ "def", "get_client", "(", "self", ")", ":", "if", "self", ".", "_ssh", "is", "None", ":", "self", ".", "_connect", "(", ")", "return", "self", ".", "_ssh", "else", ":", "try", ":", "chan", "=", "self", ".", "_ssh", ".", "get_transport", "(", ")", ...
Gets the SSH client. This will check that the connection is still alive first, and reconnect if necessary.
[ "Gets", "the", "SSH", "client", "." ]
b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b
https://github.com/VisTrails/tej/blob/b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b/tej/submission.py#L220-L238
train
VisTrails/tej
tej/submission.py
RemoteQueue._call
def _call(self, cmd, get_output): """Calls a command through the SSH connection. Remote stderr gets printed to this program's stderr. Output is captured and may be returned. """ server_err = self.server_logger() chan = self.get_client().get_transport().open_session() ...
python
def _call(self, cmd, get_output): """Calls a command through the SSH connection. Remote stderr gets printed to this program's stderr. Output is captured and may be returned. """ server_err = self.server_logger() chan = self.get_client().get_transport().open_session() ...
[ "def", "_call", "(", "self", ",", "cmd", ",", "get_output", ")", ":", "server_err", "=", "self", ".", "server_logger", "(", ")", "chan", "=", "self", ".", "get_client", "(", ")", ".", "get_transport", "(", ")", ".", "open_session", "(", ")", "try", "...
Calls a command through the SSH connection. Remote stderr gets printed to this program's stderr. Output is captured and may be returned.
[ "Calls", "a", "command", "through", "the", "SSH", "connection", "." ]
b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b
https://github.com/VisTrails/tej/blob/b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b/tej/submission.py#L243-L277
train
VisTrails/tej
tej/submission.py
RemoteQueue.check_call
def check_call(self, cmd): """Calls a command through SSH. """ ret, _ = self._call(cmd, False) if ret != 0: # pragma: no cover raise RemoteCommandFailure(command=cmd, ret=ret)
python
def check_call(self, cmd): """Calls a command through SSH. """ ret, _ = self._call(cmd, False) if ret != 0: # pragma: no cover raise RemoteCommandFailure(command=cmd, ret=ret)
[ "def", "check_call", "(", "self", ",", "cmd", ")", ":", "ret", ",", "_", "=", "self", ".", "_call", "(", "cmd", ",", "False", ")", "if", "ret", "!=", "0", ":", "# pragma: no cover", "raise", "RemoteCommandFailure", "(", "command", "=", "cmd", ",", "r...
Calls a command through SSH.
[ "Calls", "a", "command", "through", "SSH", "." ]
b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b
https://github.com/VisTrails/tej/blob/b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b/tej/submission.py#L279-L284
train
VisTrails/tej
tej/submission.py
RemoteQueue.check_output
def check_output(self, cmd): """Calls a command through SSH and returns its output. """ ret, output = self._call(cmd, True) if ret != 0: # pragma: no cover raise RemoteCommandFailure(command=cmd, ret=ret) logger.debug("Output: %r", output) return output
python
def check_output(self, cmd): """Calls a command through SSH and returns its output. """ ret, output = self._call(cmd, True) if ret != 0: # pragma: no cover raise RemoteCommandFailure(command=cmd, ret=ret) logger.debug("Output: %r", output) return output
[ "def", "check_output", "(", "self", ",", "cmd", ")", ":", "ret", ",", "output", "=", "self", ".", "_call", "(", "cmd", ",", "True", ")", "if", "ret", "!=", "0", ":", "# pragma: no cover", "raise", "RemoteCommandFailure", "(", "command", "=", "cmd", ","...
Calls a command through SSH and returns its output.
[ "Calls", "a", "command", "through", "SSH", "and", "returns", "its", "output", "." ]
b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b
https://github.com/VisTrails/tej/blob/b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b/tej/submission.py#L286-L293
train
VisTrails/tej
tej/submission.py
RemoteQueue._resolve_queue
def _resolve_queue(self, queue, depth=0, links=None): """Finds the location of tej's queue directory on the server. The `queue` set when constructing this `RemoteQueue` might be relative to the home directory and might contain ``~user`` placeholders. Also, each queue may in fact be a li...
python
def _resolve_queue(self, queue, depth=0, links=None): """Finds the location of tej's queue directory on the server. The `queue` set when constructing this `RemoteQueue` might be relative to the home directory and might contain ``~user`` placeholders. Also, each queue may in fact be a li...
[ "def", "_resolve_queue", "(", "self", ",", "queue", ",", "depth", "=", "0", ",", "links", "=", "None", ")", ":", "if", "depth", "==", "0", ":", "logger", ".", "debug", "(", "\"resolve_queue(%s)\"", ",", "queue", ")", "answer", "=", "self", ".", "chec...
Finds the location of tej's queue directory on the server. The `queue` set when constructing this `RemoteQueue` might be relative to the home directory and might contain ``~user`` placeholders. Also, each queue may in fact be a link to another path (a file containing the string ``tejdir...
[ "Finds", "the", "location", "of", "tej", "s", "queue", "directory", "on", "the", "server", "." ]
b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b
https://github.com/VisTrails/tej/blob/b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b/tej/submission.py#L295-L353
train
VisTrails/tej
tej/submission.py
RemoteQueue._get_queue
def _get_queue(self): """Gets the actual location of the queue, or None. """ if self._queue is None: self._links = [] queue, depth = self._resolve_queue(self.queue, links=self._links) if queue is None and depth > 0: raise QueueLinkBroken ...
python
def _get_queue(self): """Gets the actual location of the queue, or None. """ if self._queue is None: self._links = [] queue, depth = self._resolve_queue(self.queue, links=self._links) if queue is None and depth > 0: raise QueueLinkBroken ...
[ "def", "_get_queue", "(", "self", ")", ":", "if", "self", ".", "_queue", "is", "None", ":", "self", ".", "_links", "=", "[", "]", "queue", ",", "depth", "=", "self", ".", "_resolve_queue", "(", "self", ".", "queue", ",", "links", "=", "self", ".", ...
Gets the actual location of the queue, or None.
[ "Gets", "the", "actual", "location", "of", "the", "queue", "or", "None", "." ]
b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b
https://github.com/VisTrails/tej/blob/b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b/tej/submission.py#L355-L364
train
VisTrails/tej
tej/submission.py
RemoteQueue.setup
def setup(self, links=None, force=False, only_links=False): """Installs the runtime at the target location. This will not replace an existing installation, unless `force` is True. After installation, creates links to this installation at the specified locations. """ if ...
python
def setup(self, links=None, force=False, only_links=False): """Installs the runtime at the target location. This will not replace an existing installation, unless `force` is True. After installation, creates links to this installation at the specified locations. """ if ...
[ "def", "setup", "(", "self", ",", "links", "=", "None", ",", "force", "=", "False", ",", "only_links", "=", "False", ")", ":", "if", "not", "links", ":", "links", "=", "[", "]", "if", "only_links", ":", "logger", ".", "info", "(", "\"Only creating li...
Installs the runtime at the target location. This will not replace an existing installation, unless `force` is True. After installation, creates links to this installation at the specified locations.
[ "Installs", "the", "runtime", "at", "the", "target", "location", "." ]
b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b
https://github.com/VisTrails/tej/blob/b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b/tej/submission.py#L366-L411
train
VisTrails/tej
tej/submission.py
RemoteQueue._setup
def _setup(self): """Actually installs the runtime. """ # Expands ~user in queue if self.queue.path[0:1] == b'/': queue = self.queue else: if self.queue.path[0:1] == b'~': output = self.check_output('echo %s' % ...
python
def _setup(self): """Actually installs the runtime. """ # Expands ~user in queue if self.queue.path[0:1] == b'/': queue = self.queue else: if self.queue.path[0:1] == b'~': output = self.check_output('echo %s' % ...
[ "def", "_setup", "(", "self", ")", ":", "# Expands ~user in queue", "if", "self", ".", "queue", ".", "path", "[", "0", ":", "1", "]", "==", "b'/'", ":", "queue", "=", "self", ".", "queue", "else", ":", "if", "self", ".", "queue", ".", "path", "[", ...
Actually installs the runtime.
[ "Actually", "installs", "the", "runtime", "." ]
b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b
https://github.com/VisTrails/tej/blob/b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b/tej/submission.py#L413-L462
train
VisTrails/tej
tej/submission.py
RemoteQueue.submit
def submit(self, job_id, directory, script=None): """Submits a job to the queue. If the runtime is not there, it will be installed. If it is a broken chain of links, error. """ if job_id is None: job_id = '%s_%s_%s' % (Path(directory).unicodename, ...
python
def submit(self, job_id, directory, script=None): """Submits a job to the queue. If the runtime is not there, it will be installed. If it is a broken chain of links, error. """ if job_id is None: job_id = '%s_%s_%s' % (Path(directory).unicodename, ...
[ "def", "submit", "(", "self", ",", "job_id", ",", "directory", ",", "script", "=", "None", ")", ":", "if", "job_id", "is", "None", ":", "job_id", "=", "'%s_%s_%s'", "%", "(", "Path", "(", "directory", ")", ".", "unicodename", ",", "self", ".", "desti...
Submits a job to the queue. If the runtime is not there, it will be installed. If it is a broken chain of links, error.
[ "Submits", "a", "job", "to", "the", "queue", "." ]
b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b
https://github.com/VisTrails/tej/blob/b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b/tej/submission.py#L464-L516
train
VisTrails/tej
tej/submission.py
RemoteQueue.status
def status(self, job_id): """Gets the status of a previously-submitted job. """ check_jobid(job_id) queue = self._get_queue() if queue is None: raise QueueDoesntExist ret, output = self._call('%s %s' % ( shell_escape(queue / ...
python
def status(self, job_id): """Gets the status of a previously-submitted job. """ check_jobid(job_id) queue = self._get_queue() if queue is None: raise QueueDoesntExist ret, output = self._call('%s %s' % ( shell_escape(queue / ...
[ "def", "status", "(", "self", ",", "job_id", ")", ":", "check_jobid", "(", "job_id", ")", "queue", "=", "self", ".", "_get_queue", "(", ")", "if", "queue", "is", "None", ":", "raise", "QueueDoesntExist", "ret", ",", "output", "=", "self", ".", "_call",...
Gets the status of a previously-submitted job.
[ "Gets", "the", "status", "of", "a", "previously", "-", "submitted", "job", "." ]
b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b
https://github.com/VisTrails/tej/blob/b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b/tej/submission.py#L518-L542
train
VisTrails/tej
tej/submission.py
RemoteQueue.download
def download(self, job_id, files, **kwargs): """Downloads files from server. """ check_jobid(job_id) if not files: return if isinstance(files, string_types): files = [files] directory = False recursive = kwargs.pop('recursive', True) ...
python
def download(self, job_id, files, **kwargs): """Downloads files from server. """ check_jobid(job_id) if not files: return if isinstance(files, string_types): files = [files] directory = False recursive = kwargs.pop('recursive', True) ...
[ "def", "download", "(", "self", ",", "job_id", ",", "files", ",", "*", "*", "kwargs", ")", ":", "check_jobid", "(", "job_id", ")", "if", "not", "files", ":", "return", "if", "isinstance", "(", "files", ",", "string_types", ")", ":", "files", "=", "["...
Downloads files from server.
[ "Downloads", "files", "from", "server", "." ]
b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b
https://github.com/VisTrails/tej/blob/b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b/tej/submission.py#L544-L582
train
VisTrails/tej
tej/submission.py
RemoteQueue.kill
def kill(self, job_id): """Kills a job on the server. """ check_jobid(job_id) queue = self._get_queue() if queue is None: raise QueueDoesntExist ret, output = self._call('%s %s' % ( shell_escape(queue / 'commands/kill'), ...
python
def kill(self, job_id): """Kills a job on the server. """ check_jobid(job_id) queue = self._get_queue() if queue is None: raise QueueDoesntExist ret, output = self._call('%s %s' % ( shell_escape(queue / 'commands/kill'), ...
[ "def", "kill", "(", "self", ",", "job_id", ")", ":", "check_jobid", "(", "job_id", ")", "queue", "=", "self", ".", "_get_queue", "(", ")", "if", "queue", "is", "None", ":", "raise", "QueueDoesntExist", "ret", ",", "output", "=", "self", ".", "_call", ...
Kills a job on the server.
[ "Kills", "a", "job", "on", "the", "server", "." ]
b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b
https://github.com/VisTrails/tej/blob/b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b/tej/submission.py#L584-L601
train
VisTrails/tej
tej/submission.py
RemoteQueue.list
def list(self): """Lists the jobs on the server. """ queue = self._get_queue() if queue is None: raise QueueDoesntExist output = self.check_output('%s' % shell_escape(queue / 'commands/list')) job_id, info = None, None ...
python
def list(self): """Lists the jobs on the server. """ queue = self._get_queue() if queue is None: raise QueueDoesntExist output = self.check_output('%s' % shell_escape(queue / 'commands/list')) job_id, info = None, None ...
[ "def", "list", "(", "self", ")", ":", "queue", "=", "self", ".", "_get_queue", "(", ")", "if", "queue", "is", "None", ":", "raise", "QueueDoesntExist", "output", "=", "self", ".", "check_output", "(", "'%s'", "%", "shell_escape", "(", "queue", "/", "'c...
Lists the jobs on the server.
[ "Lists", "the", "jobs", "on", "the", "server", "." ]
b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b
https://github.com/VisTrails/tej/blob/b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b/tej/submission.py#L624-L646
train
jaraco/jaraco.text
jaraco/text.py
multi_substitution
def multi_substitution(*substitutions): """ Take a sequence of pairs specifying substitutions, and create a function that performs those substitutions. >>> multi_substitution(('foo', 'bar'), ('bar', 'baz'))('foo') 'baz' """ substitutions = itertools.starmap(substitution, substitutions) # compose function appli...
python
def multi_substitution(*substitutions): """ Take a sequence of pairs specifying substitutions, and create a function that performs those substitutions. >>> multi_substitution(('foo', 'bar'), ('bar', 'baz'))('foo') 'baz' """ substitutions = itertools.starmap(substitution, substitutions) # compose function appli...
[ "def", "multi_substitution", "(", "*", "substitutions", ")", ":", "substitutions", "=", "itertools", ".", "starmap", "(", "substitution", ",", "substitutions", ")", "# compose function applies last function first, so reverse the", "# substitutions to get the expected order.", ...
Take a sequence of pairs specifying substitutions, and create a function that performs those substitutions. >>> multi_substitution(('foo', 'bar'), ('bar', 'baz'))('foo') 'baz'
[ "Take", "a", "sequence", "of", "pairs", "specifying", "substitutions", "and", "create", "a", "function", "that", "performs", "those", "substitutions", "." ]
0fe070e9241cb1fdb737516a3f57da94a2618376
https://github.com/jaraco/jaraco.text/blob/0fe070e9241cb1fdb737516a3f57da94a2618376/jaraco/text.py#L20-L32
train
jaraco/jaraco.text
jaraco/text.py
simple_html_strip
def simple_html_strip(s): r""" Remove HTML from the string `s`. >>> str(simple_html_strip('')) '' >>> print(simple_html_strip('A <bold>stormy</bold> day in paradise')) A stormy day in paradise >>> print(simple_html_strip('Somebody <!-- do not --> tell the truth.')) Somebody tell the truth. >>> print(simpl...
python
def simple_html_strip(s): r""" Remove HTML from the string `s`. >>> str(simple_html_strip('')) '' >>> print(simple_html_strip('A <bold>stormy</bold> day in paradise')) A stormy day in paradise >>> print(simple_html_strip('Somebody <!-- do not --> tell the truth.')) Somebody tell the truth. >>> print(simpl...
[ "def", "simple_html_strip", "(", "s", ")", ":", "html_stripper", "=", "re", ".", "compile", "(", "'(<!--.*?-->)|(<[^>]*>)|([^<]+)'", ",", "re", ".", "DOTALL", ")", "texts", "=", "(", "match", ".", "group", "(", "3", ")", "or", "''", "for", "match", "in",...
r""" Remove HTML from the string `s`. >>> str(simple_html_strip('')) '' >>> print(simple_html_strip('A <bold>stormy</bold> day in paradise')) A stormy day in paradise >>> print(simple_html_strip('Somebody <!-- do not --> tell the truth.')) Somebody tell the truth. >>> print(simple_html_strip('What about<br...
[ "r", "Remove", "HTML", "from", "the", "string", "s", "." ]
0fe070e9241cb1fdb737516a3f57da94a2618376
https://github.com/jaraco/jaraco.text/blob/0fe070e9241cb1fdb737516a3f57da94a2618376/jaraco/text.py#L279-L302
train
jaraco/jaraco.text
jaraco/text.py
remove_prefix
def remove_prefix(text, prefix): """ Remove the prefix from the text if it exists. >>> remove_prefix('underwhelming performance', 'underwhelming ') 'performance' >>> remove_prefix('something special', 'sample') 'something special' """ null, prefix, rest = text.rpartition(prefix) return rest
python
def remove_prefix(text, prefix): """ Remove the prefix from the text if it exists. >>> remove_prefix('underwhelming performance', 'underwhelming ') 'performance' >>> remove_prefix('something special', 'sample') 'something special' """ null, prefix, rest = text.rpartition(prefix) return rest
[ "def", "remove_prefix", "(", "text", ",", "prefix", ")", ":", "null", ",", "prefix", ",", "rest", "=", "text", ".", "rpartition", "(", "prefix", ")", "return", "rest" ]
Remove the prefix from the text if it exists. >>> remove_prefix('underwhelming performance', 'underwhelming ') 'performance' >>> remove_prefix('something special', 'sample') 'something special'
[ "Remove", "the", "prefix", "from", "the", "text", "if", "it", "exists", "." ]
0fe070e9241cb1fdb737516a3f57da94a2618376
https://github.com/jaraco/jaraco.text/blob/0fe070e9241cb1fdb737516a3f57da94a2618376/jaraco/text.py#L378-L389
train
jaraco/jaraco.text
jaraco/text.py
remove_suffix
def remove_suffix(text, suffix): """ Remove the suffix from the text if it exists. >>> remove_suffix('name.git', '.git') 'name' >>> remove_suffix('something special', 'sample') 'something special' """ rest, suffix, null = text.partition(suffix) return rest
python
def remove_suffix(text, suffix): """ Remove the suffix from the text if it exists. >>> remove_suffix('name.git', '.git') 'name' >>> remove_suffix('something special', 'sample') 'something special' """ rest, suffix, null = text.partition(suffix) return rest
[ "def", "remove_suffix", "(", "text", ",", "suffix", ")", ":", "rest", ",", "suffix", ",", "null", "=", "text", ".", "partition", "(", "suffix", ")", "return", "rest" ]
Remove the suffix from the text if it exists. >>> remove_suffix('name.git', '.git') 'name' >>> remove_suffix('something special', 'sample') 'something special'
[ "Remove", "the", "suffix", "from", "the", "text", "if", "it", "exists", "." ]
0fe070e9241cb1fdb737516a3f57da94a2618376
https://github.com/jaraco/jaraco.text/blob/0fe070e9241cb1fdb737516a3f57da94a2618376/jaraco/text.py#L392-L403
train
jaraco/jaraco.text
jaraco/text.py
Stripper.common_prefix
def common_prefix(s1, s2): """ Return the common prefix of two lines. """ index = min(len(s1), len(s2)) while s1[:index] != s2[:index]: index -= 1 return s1[:index]
python
def common_prefix(s1, s2): """ Return the common prefix of two lines. """ index = min(len(s1), len(s2)) while s1[:index] != s2[:index]: index -= 1 return s1[:index]
[ "def", "common_prefix", "(", "s1", ",", "s2", ")", ":", "index", "=", "min", "(", "len", "(", "s1", ")", ",", "len", "(", "s2", ")", ")", "while", "s1", "[", ":", "index", "]", "!=", "s2", "[", ":", "index", "]", ":", "index", "-=", "1", "r...
Return the common prefix of two lines.
[ "Return", "the", "common", "prefix", "of", "two", "lines", "." ]
0fe070e9241cb1fdb737516a3f57da94a2618376
https://github.com/jaraco/jaraco.text/blob/0fe070e9241cb1fdb737516a3f57da94a2618376/jaraco/text.py#L368-L375
train
stevearc/pyramid_webpack
pyramid_webpack/jinja2ext.py
WebpackExtension._get_graph
def _get_graph(self, ctx, bundle, extensions, caller=None): """ Run a graph and render the tag contents for each output """ request = ctx.get('request') if request is None: request = get_current_request() if ':' in bundle: config_name, bundle = bundle.split(':') ...
python
def _get_graph(self, ctx, bundle, extensions, caller=None): """ Run a graph and render the tag contents for each output """ request = ctx.get('request') if request is None: request = get_current_request() if ':' in bundle: config_name, bundle = bundle.split(':') ...
[ "def", "_get_graph", "(", "self", ",", "ctx", ",", "bundle", ",", "extensions", ",", "caller", "=", "None", ")", ":", "request", "=", "ctx", ".", "get", "(", "'request'", ")", "if", "request", "is", "None", ":", "request", "=", "get_current_request", "...
Run a graph and render the tag contents for each output
[ "Run", "a", "graph", "and", "render", "the", "tag", "contents", "for", "each", "output" ]
4fcad26271fd6e8c270e19c7943240fea6d8c484
https://github.com/stevearc/pyramid_webpack/blob/4fcad26271fd6e8c270e19c7943240fea6d8c484/pyramid_webpack/jinja2ext.py#L60-L71
train
GaretJax/lancet
lancet/commands/workflow.py
activate
def activate(lancet, method, project): """Switch to this project.""" with taskstatus("Looking up project") as ts: if method == "key": func = get_project_keys elif method == "dir": func = get_project_keys for key, project_path in func(lancet): if key.l...
python
def activate(lancet, method, project): """Switch to this project.""" with taskstatus("Looking up project") as ts: if method == "key": func = get_project_keys elif method == "dir": func = get_project_keys for key, project_path in func(lancet): if key.l...
[ "def", "activate", "(", "lancet", ",", "method", ",", "project", ")", ":", "with", "taskstatus", "(", "\"Looking up project\"", ")", "as", "ts", ":", "if", "method", "==", "\"key\"", ":", "func", "=", "get_project_keys", "elif", "method", "==", "\"dir\"", ...
Switch to this project.
[ "Switch", "to", "this", "project", "." ]
cf438c5c6166b18ee0dc5ffce55220793019bb95
https://github.com/GaretJax/lancet/blob/cf438c5c6166b18ee0dc5ffce55220793019bb95/lancet/commands/workflow.py#L24-L56
train
GaretJax/lancet
lancet/commands/workflow.py
workon
def workon(ctx, issue_id, new, base_branch): """ Start work on a given issue. This command retrieves the issue from the issue tracker, creates and checks out a new aptly-named branch, puts the issue in the configured active, status, assigns it to you and starts a correctly linked Harvest timer. ...
python
def workon(ctx, issue_id, new, base_branch): """ Start work on a given issue. This command retrieves the issue from the issue tracker, creates and checks out a new aptly-named branch, puts the issue in the configured active, status, assigns it to you and starts a correctly linked Harvest timer. ...
[ "def", "workon", "(", "ctx", ",", "issue_id", ",", "new", ",", "base_branch", ")", ":", "lancet", "=", "ctx", ".", "obj", "if", "not", "issue_id", "and", "not", "new", ":", "raise", "click", ".", "UsageError", "(", "\"Provide either an issue ID or the --new ...
Start work on a given issue. This command retrieves the issue from the issue tracker, creates and checks out a new aptly-named branch, puts the issue in the configured active, status, assigns it to you and starts a correctly linked Harvest timer. If a branch with the same name as the one to be created...
[ "Start", "work", "on", "a", "given", "issue", "." ]
cf438c5c6166b18ee0dc5ffce55220793019bb95
https://github.com/GaretJax/lancet/blob/cf438c5c6166b18ee0dc5ffce55220793019bb95/lancet/commands/workflow.py#L78-L135
train
GaretJax/lancet
lancet/commands/workflow.py
time
def time(lancet, issue): """ Start an Harvest timer for the given issue. This command takes care of linking the timer with the issue tracker page for the given issue. If the issue is not passed to command it's taken from currently active branch. """ issue = get_issue(lancet, issue) wit...
python
def time(lancet, issue): """ Start an Harvest timer for the given issue. This command takes care of linking the timer with the issue tracker page for the given issue. If the issue is not passed to command it's taken from currently active branch. """ issue = get_issue(lancet, issue) wit...
[ "def", "time", "(", "lancet", ",", "issue", ")", ":", "issue", "=", "get_issue", "(", "lancet", ",", "issue", ")", "with", "taskstatus", "(", "\"Starting harvest timer\"", ")", "as", "ts", ":", "lancet", ".", "timer", ".", "start", "(", "issue", ")", "...
Start an Harvest timer for the given issue. This command takes care of linking the timer with the issue tracker page for the given issue. If the issue is not passed to command it's taken from currently active branch.
[ "Start", "an", "Harvest", "timer", "for", "the", "given", "issue", "." ]
cf438c5c6166b18ee0dc5ffce55220793019bb95
https://github.com/GaretJax/lancet/blob/cf438c5c6166b18ee0dc5ffce55220793019bb95/lancet/commands/workflow.py#L141-L153
train
GaretJax/lancet
lancet/commands/workflow.py
pause
def pause(ctx): """ Pause work on the current issue. This command puts the issue in the configured paused status and stops the current Harvest timer. """ lancet = ctx.obj paused_status = lancet.config.get("tracker", "paused_status") # Get the issue issue = get_issue(lancet) # ...
python
def pause(ctx): """ Pause work on the current issue. This command puts the issue in the configured paused status and stops the current Harvest timer. """ lancet = ctx.obj paused_status = lancet.config.get("tracker", "paused_status") # Get the issue issue = get_issue(lancet) # ...
[ "def", "pause", "(", "ctx", ")", ":", "lancet", "=", "ctx", ".", "obj", "paused_status", "=", "lancet", ".", "config", ".", "get", "(", "\"tracker\"", ",", "\"paused_status\"", ")", "# Get the issue", "issue", "=", "get_issue", "(", "lancet", ")", "# Make ...
Pause work on the current issue. This command puts the issue in the configured paused status and stops the current Harvest timer.
[ "Pause", "work", "on", "the", "current", "issue", "." ]
cf438c5c6166b18ee0dc5ffce55220793019bb95
https://github.com/GaretJax/lancet/blob/cf438c5c6166b18ee0dc5ffce55220793019bb95/lancet/commands/workflow.py#L158-L179
train
GaretJax/lancet
lancet/commands/workflow.py
resume
def resume(ctx): """ Resume work on the currently active issue. The issue is retrieved from the currently active branch name. """ lancet = ctx.obj username = lancet.tracker.whoami() active_status = lancet.config.get("tracker", "active_status") # Get the issue issue = get_issue(lan...
python
def resume(ctx): """ Resume work on the currently active issue. The issue is retrieved from the currently active branch name. """ lancet = ctx.obj username = lancet.tracker.whoami() active_status = lancet.config.get("tracker", "active_status") # Get the issue issue = get_issue(lan...
[ "def", "resume", "(", "ctx", ")", ":", "lancet", "=", "ctx", ".", "obj", "username", "=", "lancet", ".", "tracker", ".", "whoami", "(", ")", "active_status", "=", "lancet", ".", "config", ".", "get", "(", "\"tracker\"", ",", "\"active_status\"", ")", "...
Resume work on the currently active issue. The issue is retrieved from the currently active branch name.
[ "Resume", "work", "on", "the", "currently", "active", "issue", "." ]
cf438c5c6166b18ee0dc5ffce55220793019bb95
https://github.com/GaretJax/lancet/blob/cf438c5c6166b18ee0dc5ffce55220793019bb95/lancet/commands/workflow.py#L184-L209
train
GaretJax/lancet
lancet/contrib/dploi.py
ssh
def ssh(lancet, print_cmd, environment): """ SSH into the given environment, based on the dploi configuration. """ namespace = {} with open(lancet.config.get('dploi', 'deployment_spec')) as fh: code = compile(fh.read(), 'deployment.py', 'exec') exec(code, {}, namespace) config ...
python
def ssh(lancet, print_cmd, environment): """ SSH into the given environment, based on the dploi configuration. """ namespace = {} with open(lancet.config.get('dploi', 'deployment_spec')) as fh: code = compile(fh.read(), 'deployment.py', 'exec') exec(code, {}, namespace) config ...
[ "def", "ssh", "(", "lancet", ",", "print_cmd", ",", "environment", ")", ":", "namespace", "=", "{", "}", "with", "open", "(", "lancet", ".", "config", ".", "get", "(", "'dploi'", ",", "'deployment_spec'", ")", ")", "as", "fh", ":", "code", "=", "comp...
SSH into the given environment, based on the dploi configuration.
[ "SSH", "into", "the", "given", "environment", "based", "on", "the", "dploi", "configuration", "." ]
cf438c5c6166b18ee0dc5ffce55220793019bb95
https://github.com/GaretJax/lancet/blob/cf438c5c6166b18ee0dc5ffce55220793019bb95/lancet/contrib/dploi.py#L11-L28
train
GaretJax/lancet
lancet/cli.py
_setup_helper
def _setup_helper(): """Print the shell integration code.""" base = os.path.abspath(os.path.dirname(__file__)) helper = os.path.join(base, "helper.sh") with open(helper) as fh: click.echo(fh.read())
python
def _setup_helper(): """Print the shell integration code.""" base = os.path.abspath(os.path.dirname(__file__)) helper = os.path.join(base, "helper.sh") with open(helper) as fh: click.echo(fh.read())
[ "def", "_setup_helper", "(", ")", ":", "base", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", "helper", "=", "os", ".", "path", ".", "join", "(", "base", ",", "\"helper.sh\"", ")", "with",...
Print the shell integration code.
[ "Print", "the", "shell", "integration", "code", "." ]
cf438c5c6166b18ee0dc5ffce55220793019bb95
https://github.com/GaretJax/lancet/blob/cf438c5c6166b18ee0dc5ffce55220793019bb95/lancet/cli.py#L273-L278
train
GaretJax/lancet
lancet/cli.py
_commands
def _commands(ctx): """Prints a list of commands for shell completion hooks.""" ctx = ctx.parent ctx.show_hidden_subcommands = False main = ctx.command for subcommand in main.list_commands(ctx): cmd = main.get_command(ctx, subcommand) if cmd is None: continue hel...
python
def _commands(ctx): """Prints a list of commands for shell completion hooks.""" ctx = ctx.parent ctx.show_hidden_subcommands = False main = ctx.command for subcommand in main.list_commands(ctx): cmd = main.get_command(ctx, subcommand) if cmd is None: continue hel...
[ "def", "_commands", "(", "ctx", ")", ":", "ctx", "=", "ctx", ".", "parent", "ctx", ".", "show_hidden_subcommands", "=", "False", "main", "=", "ctx", ".", "command", "for", "subcommand", "in", "main", ".", "list_commands", "(", "ctx", ")", ":", "cmd", "...
Prints a list of commands for shell completion hooks.
[ "Prints", "a", "list", "of", "commands", "for", "shell", "completion", "hooks", "." ]
cf438c5c6166b18ee0dc5ffce55220793019bb95
https://github.com/GaretJax/lancet/blob/cf438c5c6166b18ee0dc5ffce55220793019bb95/lancet/cli.py#L283-L294
train
GaretJax/lancet
lancet/cli.py
_arguments
def _arguments(ctx, command_name=None): """Prints a list of arguments for shell completion hooks. If a command name is given, returns the arguments for that subcommand. The command name has to refer to a command; aliases are not supported. """ ctx = ctx.parent main = ctx.command if command_...
python
def _arguments(ctx, command_name=None): """Prints a list of arguments for shell completion hooks. If a command name is given, returns the arguments for that subcommand. The command name has to refer to a command; aliases are not supported. """ ctx = ctx.parent main = ctx.command if command_...
[ "def", "_arguments", "(", "ctx", ",", "command_name", "=", "None", ")", ":", "ctx", "=", "ctx", ".", "parent", "main", "=", "ctx", ".", "command", "if", "command_name", ":", "command", "=", "main", ".", "get_command", "(", "ctx", ",", "command_name", "...
Prints a list of arguments for shell completion hooks. If a command name is given, returns the arguments for that subcommand. The command name has to refer to a command; aliases are not supported.
[ "Prints", "a", "list", "of", "arguments", "for", "shell", "completion", "hooks", "." ]
cf438c5c6166b18ee0dc5ffce55220793019bb95
https://github.com/GaretJax/lancet/blob/cf438c5c6166b18ee0dc5ffce55220793019bb95/lancet/cli.py#L300-L338
train
GaretJax/lancet
lancet/cli.py
_autocomplete
def _autocomplete(ctx, shell): """Print the shell autocompletion code.""" if not shell: shell = os.environ.get("SHELL", "") shell = os.path.basename(shell).lower() if not shell: click.secho( "Your shell could not be detected, please pass its name " "as the arg...
python
def _autocomplete(ctx, shell): """Print the shell autocompletion code.""" if not shell: shell = os.environ.get("SHELL", "") shell = os.path.basename(shell).lower() if not shell: click.secho( "Your shell could not be detected, please pass its name " "as the arg...
[ "def", "_autocomplete", "(", "ctx", ",", "shell", ")", ":", "if", "not", "shell", ":", "shell", "=", "os", ".", "environ", ".", "get", "(", "\"SHELL\"", ",", "\"\"", ")", "shell", "=", "os", ".", "path", ".", "basename", "(", "shell", ")", ".", "...
Print the shell autocompletion code.
[ "Print", "the", "shell", "autocompletion", "code", "." ]
cf438c5c6166b18ee0dc5ffce55220793019bb95
https://github.com/GaretJax/lancet/blob/cf438c5c6166b18ee0dc5ffce55220793019bb95/lancet/cli.py#L344-L369
train
OCHA-DAP/hdx-python-utilities
src/hdx/utilities/__init__.py
raisefrom
def raisefrom(exc_type, message, exc): # type: (Any, str, BaseException) -> None """Call Python 3 raise from or emulate it for Python 2 Args: exc_type (Any): Type of Exception message (str): Error message to display exc (BaseException): original exception Returns: None ...
python
def raisefrom(exc_type, message, exc): # type: (Any, str, BaseException) -> None """Call Python 3 raise from or emulate it for Python 2 Args: exc_type (Any): Type of Exception message (str): Error message to display exc (BaseException): original exception Returns: None ...
[ "def", "raisefrom", "(", "exc_type", ",", "message", ",", "exc", ")", ":", "# type: (Any, str, BaseException) -> None", "if", "sys", ".", "version_info", "[", ":", "2", "]", ">=", "(", "3", ",", "2", ")", ":", "six", ".", "raise_from", "(", "exc_type", "...
Call Python 3 raise from or emulate it for Python 2 Args: exc_type (Any): Type of Exception message (str): Error message to display exc (BaseException): original exception Returns: None
[ "Call", "Python", "3", "raise", "from", "or", "emulate", "it", "for", "Python", "2" ]
9c89e0aa5afac2c002b02a2d8f0e5b91eeb3d2a3
https://github.com/OCHA-DAP/hdx-python-utilities/blob/9c89e0aa5afac2c002b02a2d8f0e5b91eeb3d2a3/src/hdx/utilities/__init__.py#L7-L23
train
RockFeng0/rtsf
rtsf/p_executer.py
Runner.init_runner
def init_runner(self, parser, tracers, projinfo): ''' initial some instances for preparing to run test case @note: should not override @param parser: instance of TestCaseParser @param tracers: dict type for the instance of Tracer. Such as {"":tracer_obj} or {"192.168.0.1:5555":trace...
python
def init_runner(self, parser, tracers, projinfo): ''' initial some instances for preparing to run test case @note: should not override @param parser: instance of TestCaseParser @param tracers: dict type for the instance of Tracer. Such as {"":tracer_obj} or {"192.168.0.1:5555":trace...
[ "def", "init_runner", "(", "self", ",", "parser", ",", "tracers", ",", "projinfo", ")", ":", "self", ".", "parser", "=", "parser", "self", ".", "tracers", "=", "tracers", "self", ".", "proj_info", "=", "projinfo" ]
initial some instances for preparing to run test case @note: should not override @param parser: instance of TestCaseParser @param tracers: dict type for the instance of Tracer. Such as {"":tracer_obj} or {"192.168.0.1:5555":tracer_obj1, "192.168.0.2:5555":tracer_obj2} @param proj_i...
[ "initial", "some", "instances", "for", "preparing", "to", "run", "test", "case" ]
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_executer.py#L227-L243
train
RockFeng0/rtsf
rtsf/p_executer.py
Runner._run_grid_multiprocess
def _run_grid_multiprocess(self, func, iterables): ''' running case with mutil process to support selenium grid-mode(multiple web) and appium grid-mode(multiple devices). @param func: function object @param iterables: iterable objects ''' multiprocessing.freeze_support() ...
python
def _run_grid_multiprocess(self, func, iterables): ''' running case with mutil process to support selenium grid-mode(multiple web) and appium grid-mode(multiple devices). @param func: function object @param iterables: iterable objects ''' multiprocessing.freeze_support() ...
[ "def", "_run_grid_multiprocess", "(", "self", ",", "func", ",", "iterables", ")", ":", "multiprocessing", ".", "freeze_support", "(", ")", "pool", "=", "multiprocessing", ".", "Pool", "(", ")", "pool_tracers", "=", "pool", ".", "map", "(", "func", ",", "it...
running case with mutil process to support selenium grid-mode(multiple web) and appium grid-mode(multiple devices). @param func: function object @param iterables: iterable objects
[ "running", "case", "with", "mutil", "process", "to", "support", "selenium", "grid", "-", "mode", "(", "multiple", "web", ")", "and", "appium", "grid", "-", "mode", "(", "multiple", "devices", ")", "." ]
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_executer.py#L282-L294
train
RockFeng0/rtsf
rtsf/p_executer.py
Runner._run_grid_multithread
def _run_grid_multithread(self, func, iterables): ''' running case with mutil process to support selenium grid-mode(multiple web) and appium grid-mode(multiple devices). @param func: function object @param iterables: iterable objects ''' f = lambda x: threading....
python
def _run_grid_multithread(self, func, iterables): ''' running case with mutil process to support selenium grid-mode(multiple web) and appium grid-mode(multiple devices). @param func: function object @param iterables: iterable objects ''' f = lambda x: threading....
[ "def", "_run_grid_multithread", "(", "self", ",", "func", ",", "iterables", ")", ":", "f", "=", "lambda", "x", ":", "threading", ".", "Thread", "(", "target", "=", "func", ",", "args", "=", "(", "x", ",", ")", ")", "threads", "=", "map", "(", "f", ...
running case with mutil process to support selenium grid-mode(multiple web) and appium grid-mode(multiple devices). @param func: function object @param iterables: iterable objects
[ "running", "case", "with", "mutil", "process", "to", "support", "selenium", "grid", "-", "mode", "(", "multiple", "web", ")", "and", "appium", "grid", "-", "mode", "(", "multiple", "devices", ")", "." ]
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_executer.py#L296-L307
train
RockFeng0/rtsf
rtsf/p_common.py
init_project_env
def init_project_env(subject='Automation', proj_path = None, sysencoding = "utf-8", debug = False): ''' Set the environment for pyrunner ''' # if sysencoding: # set_sys_encode(sysencoding) if not proj_path: try: executable_file_path = os.path.dirname(os....
python
def init_project_env(subject='Automation', proj_path = None, sysencoding = "utf-8", debug = False): ''' Set the environment for pyrunner ''' # if sysencoding: # set_sys_encode(sysencoding) if not proj_path: try: executable_file_path = os.path.dirname(os....
[ "def", "init_project_env", "(", "subject", "=", "'Automation'", ",", "proj_path", "=", "None", ",", "sysencoding", "=", "\"utf-8\"", ",", "debug", "=", "False", ")", ":", "# if sysencoding:\r", "# set_sys_encode(sysencoding)\r", "if", "not", "proj_path", ...
Set the environment for pyrunner
[ "Set", "the", "environment", "for", "pyrunner" ]
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L76-L111
train
RockFeng0/rtsf
rtsf/p_common.py
seqfy
def seqfy(strs): ''' 序列化 字符串--->实际效果是,为字符串,添加行号,返回字符串 Sampe usage: strs = ["", None, u"First-line\nSecond-line\nThird-line", u"没有换行符"] for s in strs: print "---" result = seqfy(s) print result print unseqfy(result) ''' if no...
python
def seqfy(strs): ''' 序列化 字符串--->实际效果是,为字符串,添加行号,返回字符串 Sampe usage: strs = ["", None, u"First-line\nSecond-line\nThird-line", u"没有换行符"] for s in strs: print "---" result = seqfy(s) print result print unseqfy(result) ''' if no...
[ "def", "seqfy", "(", "strs", ")", ":", "if", "not", "strs", ":", "return", "result", "=", "\"\"", "seq", "=", "1", "ss", "=", "strs", ".", "split", "(", "\"\\n\"", ")", "for", "i", "in", "ss", ":", "if", "i", ":", "result", "=", "\"\"", ".", ...
序列化 字符串--->实际效果是,为字符串,添加行号,返回字符串 Sampe usage: strs = ["", None, u"First-line\nSecond-line\nThird-line", u"没有换行符"] for s in strs: print "---" result = seqfy(s) print result print unseqfy(result)
[ "序列化", "字符串", "---", ">", "实际效果是,为字符串,添加行号,返回字符串", "Sampe", "usage", ":", "strs", "=", "[", "None", "u", "First", "-", "line", "\\", "nSecond", "-", "line", "\\", "nThird", "-", "line", "u", "没有换行符", "]", "for", "s", "in", "strs", ":", "print", "---"...
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L786-L807
train
RockFeng0/rtsf
rtsf/p_common.py
stepfy
def stepfy(strs): ''' 步骤化 字符串 --->实际效果是, 依据 序列化的字符串,转换为 Step_%s_info 的字典, 返回字典 Sample usage: test_strs = [ "", None, u"First-line\nSecond-line\nThird-line", u'1.First-line\n2.Second-line\n3.Third-line\n', u'3.没有换行符', u'3.有换行符\n', "asdfasd...
python
def stepfy(strs): ''' 步骤化 字符串 --->实际效果是, 依据 序列化的字符串,转换为 Step_%s_info 的字典, 返回字典 Sample usage: test_strs = [ "", None, u"First-line\nSecond-line\nThird-line", u'1.First-line\n2.Second-line\n3.Third-line\n', u'3.没有换行符', u'3.有换行符\n', "asdfasd...
[ "def", "stepfy", "(", "strs", ")", ":", "result", "=", "{", "}", "prog_step", "=", "re", ".", "compile", "(", "\"^\\d+\\.\"", ")", "if", "not", "strs", ":", "return", "result", "raws", "=", "strs", ".", "split", "(", "\"\\n\"", ")", "for", "raw", "...
步骤化 字符串 --->实际效果是, 依据 序列化的字符串,转换为 Step_%s_info 的字典, 返回字典 Sample usage: test_strs = [ "", None, u"First-line\nSecond-line\nThird-line", u'1.First-line\n2.Second-line\n3.Third-line\n', u'3.没有换行符', u'3.有换行符\n', "asdfasdfsdf", "1.asdf...
[ "步骤化", "字符串", "---", ">", "实际效果是", "依据", "序列化的字符串,转换为", "Step_%s_info", "的字典,", "返回字典", "Sample", "usage", ":", "test_strs", "=", "[", "None", "u", "First", "-", "line", "\\", "nSecond", "-", "line", "\\", "nThird", "-", "line", "u", "1", ".", "First",...
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L830-L865
train
RockFeng0/rtsf
rtsf/p_common.py
map_function
def map_function(func_str, fw_action_addtion=None,bw_action_addtion=None, alias_func=None): ''' Sample usage: print map_function('set',alias_func = "ini_items");# -> ini_items print map_function('set',fw_action_addtion="action_steps_",bw_action_addtion="_for_upd",alias_func = "ini_items"); # -> a...
python
def map_function(func_str, fw_action_addtion=None,bw_action_addtion=None, alias_func=None): ''' Sample usage: print map_function('set',alias_func = "ini_items");# -> ini_items print map_function('set',fw_action_addtion="action_steps_",bw_action_addtion="_for_upd",alias_func = "ini_items"); # -> a...
[ "def", "map_function", "(", "func_str", ",", "fw_action_addtion", "=", "None", ",", "bw_action_addtion", "=", "None", ",", "alias_func", "=", "None", ")", ":", "split_action_value", "=", "re", ".", "compile", "(", "\"^(\\w+)(\\((.*)\\)$)?\"", ")", "matched", "="...
Sample usage: print map_function('set',alias_func = "ini_items");# -> ini_items print map_function('set',fw_action_addtion="action_steps_",bw_action_addtion="_for_upd",alias_func = "ini_items"); # -> action_steps_ini_items_for_upd print map_function('set(a=1,b=2,c=Test())',"action_steps_","_f...
[ "Sample", "usage", ":", "print", "map_function", "(", "set", "alias_func", "=", "ini_items", ")", ";", "#", "-", ">", "ini_items", "print", "map_function", "(", "set", "fw_action_addtion", "=", "action_steps_", "bw_action_addtion", "=", "_for_upd", "alias_func", ...
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L886-L912
train
RockFeng0/rtsf
rtsf/p_common.py
IntelligentWaitUtils.until_cmd
def until_cmd(listcmd, end_expects=None, save2logfile=None, coding = encoding): ''' 执行系统命令,并等待执行完 @param listcmd: 执行的命令,列表格式 @param end_expects: 命令执行结束,在输出的最后一行,正则搜素期望值,并设置 结果标志 @param save2logfile: 设置执行过程,保存的日志 @param coding: 设置输出编码 ''' ...
python
def until_cmd(listcmd, end_expects=None, save2logfile=None, coding = encoding): ''' 执行系统命令,并等待执行完 @param listcmd: 执行的命令,列表格式 @param end_expects: 命令执行结束,在输出的最后一行,正则搜素期望值,并设置 结果标志 @param save2logfile: 设置执行过程,保存的日志 @param coding: 设置输出编码 ''' ...
[ "def", "until_cmd", "(", "listcmd", ",", "end_expects", "=", "None", ",", "save2logfile", "=", "None", ",", "coding", "=", "encoding", ")", ":", "if", "end_expects", "and", "not", "isinstance", "(", "end_expects", ",", "p_compat", ".", "str", ")", ":", "...
执行系统命令,并等待执行完 @param listcmd: 执行的命令,列表格式 @param end_expects: 命令执行结束,在输出的最后一行,正则搜素期望值,并设置 结果标志 @param save2logfile: 设置执行过程,保存的日志 @param coding: 设置输出编码
[ "执行系统命令", "并等待执行完" ]
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L118-L151
train
RockFeng0/rtsf
rtsf/p_common.py
IntelligentWaitUtils.until
def until(method, timeout = 30, message=''): """Calls the method until the return value is not False.""" end_time = time.time() + timeout while True: try: value = method() if value: return value except: ...
python
def until(method, timeout = 30, message=''): """Calls the method until the return value is not False.""" end_time = time.time() + timeout while True: try: value = method() if value: return value except: ...
[ "def", "until", "(", "method", ",", "timeout", "=", "30", ",", "message", "=", "''", ")", ":", "end_time", "=", "time", ".", "time", "(", ")", "+", "timeout", "while", "True", ":", "try", ":", "value", "=", "method", "(", ")", "if", "value", ":",...
Calls the method until the return value is not False.
[ "Calls", "the", "method", "until", "the", "return", "value", "is", "not", "False", "." ]
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L154-L167
train
RockFeng0/rtsf
rtsf/p_common.py
FileUtils._check_format
def _check_format(file_path, content): """ check testcase format if valid """ if not content: # testcase file content is empty err_msg = u"Testcase file content is empty: {}".format(file_path) raise p_exception.FileFormatError(err_msg) elif no...
python
def _check_format(file_path, content): """ check testcase format if valid """ if not content: # testcase file content is empty err_msg = u"Testcase file content is empty: {}".format(file_path) raise p_exception.FileFormatError(err_msg) elif no...
[ "def", "_check_format", "(", "file_path", ",", "content", ")", ":", "if", "not", "content", ":", "# testcase file content is empty\r", "err_msg", "=", "u\"Testcase file content is empty: {}\"", ".", "format", "(", "file_path", ")", "raise", "p_exception", ".", "FileFo...
check testcase format if valid
[ "check", "testcase", "format", "if", "valid" ]
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L222-L233
train
RockFeng0/rtsf
rtsf/p_common.py
FileUtils._load_yaml_file
def _load_yaml_file(yaml_file): """ load yaml file and check file content format """ with io.open(yaml_file, 'r', encoding='utf-8') as stream: yaml_content = yaml.load(stream) FileUtils._check_format(yaml_file, yaml_content) return yaml_content
python
def _load_yaml_file(yaml_file): """ load yaml file and check file content format """ with io.open(yaml_file, 'r', encoding='utf-8') as stream: yaml_content = yaml.load(stream) FileUtils._check_format(yaml_file, yaml_content) return yaml_content
[ "def", "_load_yaml_file", "(", "yaml_file", ")", ":", "with", "io", ".", "open", "(", "yaml_file", ",", "'r'", ",", "encoding", "=", "'utf-8'", ")", "as", "stream", ":", "yaml_content", "=", "yaml", ".", "load", "(", "stream", ")", "FileUtils", ".", "_...
load yaml file and check file content format
[ "load", "yaml", "file", "and", "check", "file", "content", "format" ]
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L236-L242
train
RockFeng0/rtsf
rtsf/p_common.py
FileUtils._load_json_file
def _load_json_file(json_file): """ load json file and check file content format """ with io.open(json_file, encoding='utf-8') as data_file: try: json_content = json.load(data_file) except p_exception.JSONDecodeError: err_msg = u"JSO...
python
def _load_json_file(json_file): """ load json file and check file content format """ with io.open(json_file, encoding='utf-8') as data_file: try: json_content = json.load(data_file) except p_exception.JSONDecodeError: err_msg = u"JSO...
[ "def", "_load_json_file", "(", "json_file", ")", ":", "with", "io", ".", "open", "(", "json_file", ",", "encoding", "=", "'utf-8'", ")", "as", "data_file", ":", "try", ":", "json_content", "=", "json", ".", "load", "(", "data_file", ")", "except", "p_exc...
load json file and check file content format
[ "load", "json", "file", "and", "check", "file", "content", "format" ]
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L245-L256
train
RockFeng0/rtsf
rtsf/p_common.py
FileUtils._load_csv_file
def _load_csv_file(csv_file): """ load csv file and check file content format @param csv_file: csv file path e.g. csv file content: username,password test1,111111 test2,222222 test3,333333 @return ...
python
def _load_csv_file(csv_file): """ load csv file and check file content format @param csv_file: csv file path e.g. csv file content: username,password test1,111111 test2,222222 test3,333333 @return ...
[ "def", "_load_csv_file", "(", "csv_file", ")", ":", "csv_content_list", "=", "[", "]", "with", "io", ".", "open", "(", "csv_file", ",", "encoding", "=", "'utf-8'", ")", "as", "csvfile", ":", "reader", "=", "csv", ".", "DictReader", "(", "csvfile", ")", ...
load csv file and check file content format @param csv_file: csv file path e.g. csv file content: username,password test1,111111 test2,222222 test3,333333 @return list of parameter, each paramete...
[ "load", "csv", "file", "and", "check", "file", "content", "format" ]
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L259-L284
train
RockFeng0/rtsf
rtsf/p_common.py
FileSystemUtils.force_delete_file
def force_delete_file(file_path): ''' force delete a file ''' if os.path.isfile(file_path): try: os.remove(file_path) return file_path except: return FileSystemUtils.add_unique_postfix(file_path) else: ...
python
def force_delete_file(file_path): ''' force delete a file ''' if os.path.isfile(file_path): try: os.remove(file_path) return file_path except: return FileSystemUtils.add_unique_postfix(file_path) else: ...
[ "def", "force_delete_file", "(", "file_path", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "file_path", ")", ":", "try", ":", "os", ".", "remove", "(", "file_path", ")", "return", "file_path", "except", ":", "return", "FileSystemUtils", ".", "a...
force delete a file
[ "force", "delete", "a", "file" ]
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L403-L412
train
RockFeng0/rtsf
rtsf/p_common.py
ZipUtils.mkzip
def mkzip(source_dir, output_filename): '''Usage: p = r'D:\auto\env\ttest\ins\build\lib\rock4\softtest\support' mkzip(os.path.join(p, "appiumroot"),os.path.join(p, "appiumroot.zip")) unzip(os.path.join(p, "appiumroot.zip"),os.path.join(p, "appiumroot2")) ''' ...
python
def mkzip(source_dir, output_filename): '''Usage: p = r'D:\auto\env\ttest\ins\build\lib\rock4\softtest\support' mkzip(os.path.join(p, "appiumroot"),os.path.join(p, "appiumroot.zip")) unzip(os.path.join(p, "appiumroot.zip"),os.path.join(p, "appiumroot2")) ''' ...
[ "def", "mkzip", "(", "source_dir", ",", "output_filename", ")", ":", "zipf", "=", "zipfile", ".", "ZipFile", "(", "output_filename", ",", "'w'", ",", "zipfile", ".", "zlib", ".", "DEFLATED", ")", "pre_len", "=", "len", "(", "os", ".", "path", ".", "dir...
Usage: p = r'D:\auto\env\ttest\ins\build\lib\rock4\softtest\support' mkzip(os.path.join(p, "appiumroot"),os.path.join(p, "appiumroot.zip")) unzip(os.path.join(p, "appiumroot.zip"),os.path.join(p, "appiumroot2"))
[ "Usage", ":", "p", "=", "r", "D", ":", "\\", "auto", "\\", "env", "\\", "ttest", "\\", "ins", "\\", "build", "\\", "lib", "\\", "rock4", "\\", "softtest", "\\", "support", "mkzip", "(", "os", ".", "path", ".", "join", "(", "p", "appiumroot", ")",...
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L418-L431
train
RockFeng0/rtsf
rtsf/p_common.py
ModuleUtils.get_imported_module_from_file
def get_imported_module_from_file(file_path): """ import module from python file path and return imported module """ if p_compat.is_py3: imported_module = importlib.machinery.SourceFileLoader('module_name', file_path).load_module() elif p_compat.is_py2: impo...
python
def get_imported_module_from_file(file_path): """ import module from python file path and return imported module """ if p_compat.is_py3: imported_module = importlib.machinery.SourceFileLoader('module_name', file_path).load_module() elif p_compat.is_py2: impo...
[ "def", "get_imported_module_from_file", "(", "file_path", ")", ":", "if", "p_compat", ".", "is_py3", ":", "imported_module", "=", "importlib", ".", "machinery", ".", "SourceFileLoader", "(", "'module_name'", ",", "file_path", ")", ".", "load_module", "(", ")", "...
import module from python file path and return imported module
[ "import", "module", "from", "python", "file", "path", "and", "return", "imported", "module" ]
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L498-L508
train
RockFeng0/rtsf
rtsf/p_common.py
ModuleUtils.filter_module
def filter_module(module, filter_type): """ filter functions or variables from import module @params module: imported module filter_type: "function" or "variable" """ filter_type = ModuleUtils.is_function if filter_type == "function" else ModuleUtils.is_vari...
python
def filter_module(module, filter_type): """ filter functions or variables from import module @params module: imported module filter_type: "function" or "variable" """ filter_type = ModuleUtils.is_function if filter_type == "function" else ModuleUtils.is_vari...
[ "def", "filter_module", "(", "module", ",", "filter_type", ")", ":", "filter_type", "=", "ModuleUtils", ".", "is_function", "if", "filter_type", "==", "\"function\"", "else", "ModuleUtils", ".", "is_variable", "module_functions_dict", "=", "dict", "(", "filter", "...
filter functions or variables from import module @params module: imported module filter_type: "function" or "variable"
[ "filter", "functions", "or", "variables", "from", "import", "module" ]
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L511-L519
train
RockFeng0/rtsf
rtsf/p_common.py
ModuleUtils.search_conf_item
def search_conf_item(start_path, item_type, item_name): """ search expected function or variable recursive upward @param start_path: search start path item_type: "function" or "variable" item_name: function name or variable name e.g. search_...
python
def search_conf_item(start_path, item_type, item_name): """ search expected function or variable recursive upward @param start_path: search start path item_type: "function" or "variable" item_name: function name or variable name e.g. search_...
[ "def", "search_conf_item", "(", "start_path", ",", "item_type", ",", "item_name", ")", ":", "dir_path", "=", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "start_path", ")", ")", "target_file", "=", "os", ".", "path", ...
search expected function or variable recursive upward @param start_path: search start path item_type: "function" or "variable" item_name: function name or variable name e.g. search_conf_item('C:/Users/RockFeng/Desktop/s/preference.py','function','tes...
[ "search", "expected", "function", "or", "variable", "recursive", "upward" ]
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L522-L550
train
RockFeng0/rtsf
rtsf/p_common.py
SetupUtils.find_data_files
def find_data_files(source,target,patterns,isiter=False): """Locates the specified data-files and returns the matches; filesystem tree for setup's data_files in setup.py Usage: data_files = find_data_files(r"C:\Python27\Lib\site-packages\numpy\core","numpy/core",["*....
python
def find_data_files(source,target,patterns,isiter=False): """Locates the specified data-files and returns the matches; filesystem tree for setup's data_files in setup.py Usage: data_files = find_data_files(r"C:\Python27\Lib\site-packages\numpy\core","numpy/core",["*....
[ "def", "find_data_files", "(", "source", ",", "target", ",", "patterns", ",", "isiter", "=", "False", ")", ":", "if", "glob", ".", "has_magic", "(", "source", ")", "or", "glob", ".", "has_magic", "(", "target", ")", ":", "raise", "ValueError", "(", "\"...
Locates the specified data-files and returns the matches; filesystem tree for setup's data_files in setup.py Usage: data_files = find_data_files(r"C:\Python27\Lib\site-packages\numpy\core","numpy/core",["*.dll","*.pyd"]) data_files = find_data_files(r"d:\auto...
[ "Locates", "the", "specified", "data", "-", "files", "and", "returns", "the", "matches", ";", "filesystem", "tree", "for", "setup", "s", "data_files", "in", "setup", ".", "py", "Usage", ":", "data_files", "=", "find_data_files", "(", "r", "C", ":", "\\", ...
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L555-L582
train
RockFeng0/rtsf
rtsf/p_common.py
CommonUtils.convert_to_order_dict
def convert_to_order_dict(map_list): """ convert mapping in list to ordered dict @param (list) map_list [ {"a": 1}, {"b": 2} ] @return (OrderDict) OrderDict({ "a": 1, "b": 2 ...
python
def convert_to_order_dict(map_list): """ convert mapping in list to ordered dict @param (list) map_list [ {"a": 1}, {"b": 2} ] @return (OrderDict) OrderDict({ "a": 1, "b": 2 ...
[ "def", "convert_to_order_dict", "(", "map_list", ")", ":", "ordered_dict", "=", "OrderedDict", "(", ")", "for", "map_dict", "in", "map_list", ":", "ordered_dict", ".", "update", "(", "map_dict", ")", "return", "ordered_dict" ]
convert mapping in list to ordered dict @param (list) map_list [ {"a": 1}, {"b": 2} ] @return (OrderDict) OrderDict({ "a": 1, "b": 2 })
[ "convert", "mapping", "in", "list", "to", "ordered", "dict" ]
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L626-L643
train
RockFeng0/rtsf
rtsf/p_common.py
CommonUtils.get_value_from_cfg
def get_value_from_cfg(cfg_file): ''' initial the configuration with file that you specify Sample usage: config = get_value_from_cfg() return: return a dict -->config[section][option] such as config["twsm"]["dut_ip"] ...
python
def get_value_from_cfg(cfg_file): ''' initial the configuration with file that you specify Sample usage: config = get_value_from_cfg() return: return a dict -->config[section][option] such as config["twsm"]["dut_ip"] ...
[ "def", "get_value_from_cfg", "(", "cfg_file", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "cfg_file", ")", ":", "return", "cfg", "=", "{", "}", "config", "=", "ConfigParser", ".", "RawConfigParser", "(", ")", "try", ":", "config", "."...
initial the configuration with file that you specify Sample usage: config = get_value_from_cfg() return: return a dict -->config[section][option] such as config["twsm"]["dut_ip"]
[ "initial", "the", "configuration", "with", "file", "that", "you", "specify", "Sample", "usage", ":", "config", "=", "get_value_from_cfg", "()", "return", ":", "return", "a", "dict", "--", ">", "config", "[", "section", "]", "[", "option", "]", "such", "as"...
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L646-L669
train
RockFeng0/rtsf
rtsf/p_common.py
CommonUtils.get_exception_error
def get_exception_error(): ''' Get the exception info Sample usage: try: raise Exception("asdfsdfsdf") except: print common.get_exception_error() Return: return the exception infomation. ''' error_messa...
python
def get_exception_error(): ''' Get the exception info Sample usage: try: raise Exception("asdfsdfsdf") except: print common.get_exception_error() Return: return the exception infomation. ''' error_messa...
[ "def", "get_exception_error", "(", ")", ":", "error_message", "=", "\"\"", "for", "i", "in", "range", "(", "len", "(", "inspect", ".", "trace", "(", ")", ")", ")", ":", "error_line", "=", "u\"\"\"\r\n File: %s - [%s]\r\n Function: %s\r\n S...
Get the exception info Sample usage: try: raise Exception("asdfsdfsdf") except: print common.get_exception_error() Return: return the exception infomation.
[ "Get", "the", "exception", "info", "Sample", "usage", ":", "try", ":", "raise", "Exception", "(", "asdfsdfsdf", ")", "except", ":", "print", "common", ".", "get_exception_error", "()", "Return", ":", "return", "the", "exception", "infomation", "." ]
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L672-L694
train
RockFeng0/rtsf
rtsf/p_common.py
ProgressBarUtils.echo
def echo(transferred, toBeTransferred, suffix=''): ''' usage: for i in range(101): ProgressBarUtils.echo(i,100) ''' bar_len = 60 rate = transferred/float(toBeTransferred) filled_len = int(round(bar_len * rate)) ...
python
def echo(transferred, toBeTransferred, suffix=''): ''' usage: for i in range(101): ProgressBarUtils.echo(i,100) ''' bar_len = 60 rate = transferred/float(toBeTransferred) filled_len = int(round(bar_len * rate)) ...
[ "def", "echo", "(", "transferred", ",", "toBeTransferred", ",", "suffix", "=", "''", ")", ":", "bar_len", "=", "60", "rate", "=", "transferred", "/", "float", "(", "toBeTransferred", ")", "filled_len", "=", "int", "(", "round", "(", "bar_len", "*", "rate...
usage: for i in range(101): ProgressBarUtils.echo(i,100)
[ "usage", ":", "for", "i", "in", "range", "(", "101", ")", ":", "ProgressBarUtils", ".", "echo", "(", "i", "100", ")" ]
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L700-L713
train
RockFeng0/rtsf
rtsf/p_common.py
ProgressBarUtils.echo_size
def echo_size(self, transferred=1, status=None): '''Sample usage: f=lambda x,y:x+y ldata = range(10) toBeTransferred = reduce(f,range(10)) progress = ProgressBarUtils("refresh", toBeTransferred=toBeTransferred, unit="KB", chunk_siz...
python
def echo_size(self, transferred=1, status=None): '''Sample usage: f=lambda x,y:x+y ldata = range(10) toBeTransferred = reduce(f,range(10)) progress = ProgressBarUtils("refresh", toBeTransferred=toBeTransferred, unit="KB", chunk_siz...
[ "def", "echo_size", "(", "self", ",", "transferred", "=", "1", ",", "status", "=", "None", ")", ":", "self", ".", "transferred", "+=", "transferred", "# if status is not None:\r", "self", ".", "status", "=", "status", "or", "self", ".", "status", "end_str", ...
Sample usage: f=lambda x,y:x+y ldata = range(10) toBeTransferred = reduce(f,range(10)) progress = ProgressBarUtils("refresh", toBeTransferred=toBeTransferred, unit="KB", chunk_size=1.0, run_status="正在下载", fin_status="下载完成") imp...
[ "Sample", "usage", ":", "f", "=", "lambda", "x", "y", ":", "x", "+", "y", "ldata", "=", "range", "(", "10", ")", "toBeTransferred", "=", "reduce", "(", "f", "range", "(", "10", "))", "progress", "=", "ProgressBarUtils", "(", "refresh", "toBeTransferred...
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L725-L746
train
RockFeng0/rtsf
rtsf/p_common.py
ProgressBarUtils.echo_percent
def echo_percent(self,transferred=1, status=None): '''Sample usage: f=lambda x,y:x+y ldata = range(10) toBeTransferred = reduce(f,range(10)) import time progress = ProgressBarUtils("viewbar", toBeTransferred=toBeTransferred, run_sta...
python
def echo_percent(self,transferred=1, status=None): '''Sample usage: f=lambda x,y:x+y ldata = range(10) toBeTransferred = reduce(f,range(10)) import time progress = ProgressBarUtils("viewbar", toBeTransferred=toBeTransferred, run_sta...
[ "def", "echo_percent", "(", "self", ",", "transferred", "=", "1", ",", "status", "=", "None", ")", ":", "self", ".", "transferred", "+=", "transferred", "self", ".", "status", "=", "status", "or", "self", ".", "status", "end_str", "=", "\"\\r\"", "if", ...
Sample usage: f=lambda x,y:x+y ldata = range(10) toBeTransferred = reduce(f,range(10)) import time progress = ProgressBarUtils("viewbar", toBeTransferred=toBeTransferred, run_status="正在下载", fin_status="下载完成") for i in ldata:...
[ "Sample", "usage", ":", "f", "=", "lambda", "x", "y", ":", "x", "+", "y", "ldata", "=", "range", "(", "10", ")", "toBeTransferred", "=", "reduce", "(", "f", "range", "(", "10", "))", "import", "time", "progress", "=", "ProgressBarUtils", "(", "viewba...
fbc0d57edaeca86418af3942472fcc6d3e9ce591
https://github.com/RockFeng0/rtsf/blob/fbc0d57edaeca86418af3942472fcc6d3e9ce591/rtsf/p_common.py#L748-L766
train
walkr/nanoservice
benchmarks/bench_req_rep.py
start_service
def start_service(addr, n): """ Start a service """ s = Service(addr) s.register('add', lambda x, y: x + y) started = time.time() for _ in range(n): s.process() duration = time.time() - started time.sleep(0.1) print('Service stats:') util.print_stats(n, duration) return
python
def start_service(addr, n): """ Start a service """ s = Service(addr) s.register('add', lambda x, y: x + y) started = time.time() for _ in range(n): s.process() duration = time.time() - started time.sleep(0.1) print('Service stats:') util.print_stats(n, duration) return
[ "def", "start_service", "(", "addr", ",", "n", ")", ":", "s", "=", "Service", "(", "addr", ")", "s", ".", "register", "(", "'add'", ",", "lambda", "x", ",", "y", ":", "x", "+", "y", ")", "started", "=", "time", ".", "time", "(", ")", "for", "...
Start a service
[ "Start", "a", "service" ]
e2098986b1baa5f283167ae487d14f3c6c21961a
https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/benchmarks/bench_req_rep.py#L8-L21
train
walkr/nanoservice
benchmarks/bench_req_rep.py
bench
def bench(client, n): """ Benchmark n requests """ pairs = [(x, x + 1) for x in range(n)] started = time.time() for pair in pairs: res, err = client.call('add', *pair) # assert err is None duration = time.time() - started print('Client stats:') util.print_stats(n, duration)
python
def bench(client, n): """ Benchmark n requests """ pairs = [(x, x + 1) for x in range(n)] started = time.time() for pair in pairs: res, err = client.call('add', *pair) # assert err is None duration = time.time() - started print('Client stats:') util.print_stats(n, duration)
[ "def", "bench", "(", "client", ",", "n", ")", ":", "pairs", "=", "[", "(", "x", ",", "x", "+", "1", ")", "for", "x", "in", "range", "(", "n", ")", "]", "started", "=", "time", ".", "time", "(", ")", "for", "pair", "in", "pairs", ":", "res",...
Benchmark n requests
[ "Benchmark", "n", "requests" ]
e2098986b1baa5f283167ae487d14f3c6c21961a
https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/benchmarks/bench_req_rep.py#L24-L34
train
walkr/nanoservice
benchmarks/bench_pub_sub_raw.py
start_service
def start_service(addr, n): """ Start a service """ s = Subscriber(addr) s.socket.set_string_option(nanomsg.SUB, nanomsg.SUB_SUBSCRIBE, 'test') started = time.time() for _ in range(n): msg = s.socket.recv() s.socket.close() duration = time.time() - started print('Raw SUB servi...
python
def start_service(addr, n): """ Start a service """ s = Subscriber(addr) s.socket.set_string_option(nanomsg.SUB, nanomsg.SUB_SUBSCRIBE, 'test') started = time.time() for _ in range(n): msg = s.socket.recv() s.socket.close() duration = time.time() - started print('Raw SUB servi...
[ "def", "start_service", "(", "addr", ",", "n", ")", ":", "s", "=", "Subscriber", "(", "addr", ")", "s", ".", "socket", ".", "set_string_option", "(", "nanomsg", ".", "SUB", ",", "nanomsg", ".", "SUB_SUBSCRIBE", ",", "'test'", ")", "started", "=", "time...
Start a service
[ "Start", "a", "service" ]
e2098986b1baa5f283167ae487d14f3c6c21961a
https://github.com/walkr/nanoservice/blob/e2098986b1baa5f283167ae487d14f3c6c21961a/benchmarks/bench_pub_sub_raw.py#L9-L23
train
VisTrails/tej
tej/utils.py
shell_escape
def shell_escape(s): r"""Given bl"a, returns "bl\\"a". """ if isinstance(s, PosixPath): s = unicode_(s) elif isinstance(s, bytes): s = s.decode('utf-8') if not s or any(c not in safe_shell_chars for c in s): return '"%s"' % (s.replace('\\', '\\\\') ....
python
def shell_escape(s): r"""Given bl"a, returns "bl\\"a". """ if isinstance(s, PosixPath): s = unicode_(s) elif isinstance(s, bytes): s = s.decode('utf-8') if not s or any(c not in safe_shell_chars for c in s): return '"%s"' % (s.replace('\\', '\\\\') ....
[ "def", "shell_escape", "(", "s", ")", ":", "if", "isinstance", "(", "s", ",", "PosixPath", ")", ":", "s", "=", "unicode_", "(", "s", ")", "elif", "isinstance", "(", "s", ",", "bytes", ")", ":", "s", "=", "s", ".", "decode", "(", "'utf-8'", ")", ...
r"""Given bl"a, returns "bl\\"a".
[ "r", "Given", "bl", "a", "returns", "bl", "\\\\", "a", "." ]
b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b
https://github.com/VisTrails/tej/blob/b8dedaeb6bdeb650b46cfe6d85e5aa9284fc7f0b/tej/utils.py#L39-L52
train
GaretJax/lancet
lancet/commands/harvest.py
projects
def projects(lancet, query): """List Harvest projects, optionally filtered with a regexp.""" projects = lancet.timer.projects() if query: regexp = re.compile(query, flags=re.IGNORECASE) def match(project): match = regexp.search(project['name']) if match is None: ...
python
def projects(lancet, query): """List Harvest projects, optionally filtered with a regexp.""" projects = lancet.timer.projects() if query: regexp = re.compile(query, flags=re.IGNORECASE) def match(project): match = regexp.search(project['name']) if match is None: ...
[ "def", "projects", "(", "lancet", ",", "query", ")", ":", "projects", "=", "lancet", ".", "timer", ".", "projects", "(", ")", "if", "query", ":", "regexp", "=", "re", ".", "compile", "(", "query", ",", "flags", "=", "re", ".", "IGNORECASE", ")", "d...
List Harvest projects, optionally filtered with a regexp.
[ "List", "Harvest", "projects", "optionally", "filtered", "with", "a", "regexp", "." ]
cf438c5c6166b18ee0dc5ffce55220793019bb95
https://github.com/GaretJax/lancet/blob/cf438c5c6166b18ee0dc5ffce55220793019bb95/lancet/commands/harvest.py#L11-L36
train
GaretJax/lancet
lancet/commands/harvest.py
tasks
def tasks(lancet, project_id): """List Harvest tasks for the given project ID.""" for task in lancet.timer.tasks(project_id): click.echo('{:>9d} {} {}'.format( task['id'], click.style('‣', fg='yellow'), task['name']))
python
def tasks(lancet, project_id): """List Harvest tasks for the given project ID.""" for task in lancet.timer.tasks(project_id): click.echo('{:>9d} {} {}'.format( task['id'], click.style('‣', fg='yellow'), task['name']))
[ "def", "tasks", "(", "lancet", ",", "project_id", ")", ":", "for", "task", "in", "lancet", ".", "timer", ".", "tasks", "(", "project_id", ")", ":", "click", ".", "echo", "(", "'{:>9d} {} {}'", ".", "format", "(", "task", "[", "'id'", "]", ",", "click...
List Harvest tasks for the given project ID.
[ "List", "Harvest", "tasks", "for", "the", "given", "project", "ID", "." ]
cf438c5c6166b18ee0dc5ffce55220793019bb95
https://github.com/GaretJax/lancet/blob/cf438c5c6166b18ee0dc5ffce55220793019bb95/lancet/commands/harvest.py#L42-L46
train
getmillipede/millipede-python
setup.py
get_long_description
def get_long_description(): """ Retrieve the long description from DESCRIPTION.rst """ here = os.path.abspath(os.path.dirname(__file__)) with copen(os.path.join(here, 'DESCRIPTION.rst'), encoding='utf-8') as description: return description.read()
python
def get_long_description(): """ Retrieve the long description from DESCRIPTION.rst """ here = os.path.abspath(os.path.dirname(__file__)) with copen(os.path.join(here, 'DESCRIPTION.rst'), encoding='utf-8') as description: return description.read()
[ "def", "get_long_description", "(", ")", ":", "here", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", "with", "copen", "(", "os", ".", "path", ".", "join", "(", "here", ",", "'DESCRIPTION.rst...
Retrieve the long description from DESCRIPTION.rst
[ "Retrieve", "the", "long", "description", "from", "DESCRIPTION", ".", "rst" ]
ae4f1fe388906c140d12c21fee260f2338f5b9df
https://github.com/getmillipede/millipede-python/blob/ae4f1fe388906c140d12c21fee260f2338f5b9df/setup.py#L14-L19
train
IzunaDevs/SnekChek
snekchek/structure.py
flatten
def flatten(nested_list: list) -> list: """Flattens a list, ignore all the lambdas.""" return list(sorted(filter(lambda y: y is not None, list(map(lambda x: (nested_list.extend(x) # noqa: T484 if isinstance(x, list) else x), ...
python
def flatten(nested_list: list) -> list: """Flattens a list, ignore all the lambdas.""" return list(sorted(filter(lambda y: y is not None, list(map(lambda x: (nested_list.extend(x) # noqa: T484 if isinstance(x, list) else x), ...
[ "def", "flatten", "(", "nested_list", ":", "list", ")", "->", "list", ":", "return", "list", "(", "sorted", "(", "filter", "(", "lambda", "y", ":", "y", "is", "not", "None", ",", "list", "(", "map", "(", "lambda", "x", ":", "(", "nested_list", ".",...
Flattens a list, ignore all the lambdas.
[ "Flattens", "a", "list", "ignore", "all", "the", "lambdas", "." ]
fdb01bdf1ec8e79d9aae2a11d96bfb27e53a97a9
https://github.com/IzunaDevs/SnekChek/blob/fdb01bdf1ec8e79d9aae2a11d96bfb27e53a97a9/snekchek/structure.py#L14-L19
train
IzunaDevs/SnekChek
snekchek/structure.py
get_py_files
def get_py_files(dir_name: str) -> list: """Get all .py files.""" return flatten([ x for x in [["{0}/{1}".format(path, f) for f in files if f.endswith(".py")] for path, _, files in os.walk(dir_name) if not path.startswith("./build")] if x ])
python
def get_py_files(dir_name: str) -> list: """Get all .py files.""" return flatten([ x for x in [["{0}/{1}".format(path, f) for f in files if f.endswith(".py")] for path, _, files in os.walk(dir_name) if not path.startswith("./build")] if x ])
[ "def", "get_py_files", "(", "dir_name", ":", "str", ")", "->", "list", ":", "return", "flatten", "(", "[", "x", "for", "x", "in", "[", "[", "\"{0}/{1}\"", ".", "format", "(", "path", ",", "f", ")", "for", "f", "in", "files", "if", "f", ".", "ends...
Get all .py files.
[ "Get", "all", ".", "py", "files", "." ]
fdb01bdf1ec8e79d9aae2a11d96bfb27e53a97a9
https://github.com/IzunaDevs/SnekChek/blob/fdb01bdf1ec8e79d9aae2a11d96bfb27e53a97a9/snekchek/structure.py#L22-L29
train
IzunaDevs/SnekChek
snekchek/structure.py
CheckHandler.exit
def exit(self) -> None: """Raise SystemExit with correct status code and output logs.""" total = sum(len(logs) for logs in self.logs.values()) if self.json: self.logs['total'] = total print(json.dumps(self.logs, indent=self.indent)) else: for name, lo...
python
def exit(self) -> None: """Raise SystemExit with correct status code and output logs.""" total = sum(len(logs) for logs in self.logs.values()) if self.json: self.logs['total'] = total print(json.dumps(self.logs, indent=self.indent)) else: for name, lo...
[ "def", "exit", "(", "self", ")", "->", "None", ":", "total", "=", "sum", "(", "len", "(", "logs", ")", "for", "logs", "in", "self", ".", "logs", ".", "values", "(", ")", ")", "if", "self", ".", "json", ":", "self", ".", "logs", "[", "'total'", ...
Raise SystemExit with correct status code and output logs.
[ "Raise", "SystemExit", "with", "correct", "status", "code", "and", "output", "logs", "." ]
fdb01bdf1ec8e79d9aae2a11d96bfb27e53a97a9
https://github.com/IzunaDevs/SnekChek/blob/fdb01bdf1ec8e79d9aae2a11d96bfb27e53a97a9/snekchek/structure.py#L82-L101
train
IzunaDevs/SnekChek
snekchek/structure.py
CheckHandler.run_linter
def run_linter(self, linter) -> None: """Run a checker class""" self.current = linter.name if (linter.name not in self.parser["all"].as_list("linters") or linter.base_pyversion > sys.version_info): # noqa: W503 return if any(x not in self.installed for x in...
python
def run_linter(self, linter) -> None: """Run a checker class""" self.current = linter.name if (linter.name not in self.parser["all"].as_list("linters") or linter.base_pyversion > sys.version_info): # noqa: W503 return if any(x not in self.installed for x in...
[ "def", "run_linter", "(", "self", ",", "linter", ")", "->", "None", ":", "self", ".", "current", "=", "linter", ".", "name", "if", "(", "linter", ".", "name", "not", "in", "self", ".", "parser", "[", "\"all\"", "]", ".", "as_list", "(", "\"linters\""...
Run a checker class
[ "Run", "a", "checker", "class" ]
fdb01bdf1ec8e79d9aae2a11d96bfb27e53a97a9
https://github.com/IzunaDevs/SnekChek/blob/fdb01bdf1ec8e79d9aae2a11d96bfb27e53a97a9/snekchek/structure.py#L103-L117
train
getmillipede/millipede-python
millipede/__init__.py
read_rcfile
def read_rcfile(): """ Try to read a rcfile from a list of paths """ files = [ '{}/.millipederc'.format(os.environ.get('HOME')), '/usr/local/etc/millipederc', '/etc/millipederc', ] for filepath in files: if os.path.isfile(filepath): with open(filepath)...
python
def read_rcfile(): """ Try to read a rcfile from a list of paths """ files = [ '{}/.millipederc'.format(os.environ.get('HOME')), '/usr/local/etc/millipederc', '/etc/millipederc', ] for filepath in files: if os.path.isfile(filepath): with open(filepath)...
[ "def", "read_rcfile", "(", ")", ":", "files", "=", "[", "'{}/.millipederc'", ".", "format", "(", "os", ".", "environ", ".", "get", "(", "'HOME'", ")", ")", ",", "'/usr/local/etc/millipederc'", ",", "'/etc/millipederc'", ",", "]", "for", "filepath", "in", "...
Try to read a rcfile from a list of paths
[ "Try", "to", "read", "a", "rcfile", "from", "a", "list", "of", "paths" ]
ae4f1fe388906c140d12c21fee260f2338f5b9df
https://github.com/getmillipede/millipede-python/blob/ae4f1fe388906c140d12c21fee260f2338f5b9df/millipede/__init__.py#L18-L31
train
getmillipede/millipede-python
millipede/__init__.py
parse_rcfile
def parse_rcfile(rcfile): """ Parses rcfile Invalid lines are ignored with a warning """ def parse_bool(value): """Parse boolean string""" value = value.lower() if value in ['yes', 'true']: return True elif value in ['no', 'false']: return Fal...
python
def parse_rcfile(rcfile): """ Parses rcfile Invalid lines are ignored with a warning """ def parse_bool(value): """Parse boolean string""" value = value.lower() if value in ['yes', 'true']: return True elif value in ['no', 'false']: return Fal...
[ "def", "parse_rcfile", "(", "rcfile", ")", ":", "def", "parse_bool", "(", "value", ")", ":", "\"\"\"Parse boolean string\"\"\"", "value", "=", "value", ".", "lower", "(", ")", "if", "value", "in", "[", "'yes'", ",", "'true'", "]", ":", "return", "True", ...
Parses rcfile Invalid lines are ignored with a warning
[ "Parses", "rcfile" ]
ae4f1fe388906c140d12c21fee260f2338f5b9df
https://github.com/getmillipede/millipede-python/blob/ae4f1fe388906c140d12c21fee260f2338f5b9df/millipede/__init__.py#L33-L72
train