sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
def list_reced_topics(self, user_alias=None, start=0):
"""
推荐的话题列表
:param user_alias: 指定用户,默认当前
:param start: 翻页
:return: 带下一页的列表
"""
user_alias = user_alias or self.api.user_alias
xml = self.api.xml(API_GROUP_LIST_USER_RECED_TOPICS % user_alias, ... | 推荐的话题列表
:param user_alias: 指定用户,默认当前
:param start: 翻页
:return: 带下一页的列表 | entailment |
def add_topic(self, group_alias, title, content):
"""
创建话题(小心验证码~)
:param group_alias: 小组ID
:param title: 标题
:param content: 内容
:return: bool
"""
xml = self.api.req(API_GROUP_ADD_TOPIC % group_alias, 'post', data={
'ck': self.api.ck(),... | 创建话题(小心验证码~)
:param group_alias: 小组ID
:param title: 标题
:param content: 内容
:return: bool | entailment |
def remove_topic(self, topic_id):
"""
删除话题(需要先删除所有评论,使用默认参数)
:param topic_id: 话题ID
:return: None
"""
comment_start = 0
while comment_start is not None:
comments = self.list_comments(topic_id, comment_start)
for comment in comments[... | 删除话题(需要先删除所有评论,使用默认参数)
:param topic_id: 话题ID
:return: None | entailment |
def update_topic(self, topic_id, title, content):
"""
更新话题
:param topic_id: 话题ID
:param title: 标题
:param content: 内容
:return: bool
"""
xml = self.api.req(API_GROUP_UPDATE_TOPIC % topic_id, 'post', data={
'ck': self.api.ck(),
... | 更新话题
:param topic_id: 话题ID
:param title: 标题
:param content: 内容
:return: bool | entailment |
def list_comments(self, topic_id, start=0):
"""
回复列表
:param topic_id: 话题ID
:param start: 翻页
:return: 带下一页的列表
"""
xml = self.api.xml(API_GROUP_GET_TOPIC % topic_id, params={'start': start})
xml_results = xml.xpath('//ul[@id="comments"]/li')
... | 回复列表
:param topic_id: 话题ID
:param start: 翻页
:return: 带下一页的列表 | entailment |
def add_comment(self, topic_id, content, reply_id=None):
"""
添加评论
:param topic_id: 话题ID
:param content: 内容
:param reply_id: 回复ID
:return: None
"""
return self.api.req(API_GROUP_ADD_COMMENT % topic_id, 'post', data={
'ck': self.api.ck()... | 添加评论
:param topic_id: 话题ID
:param content: 内容
:param reply_id: 回复ID
:return: None | entailment |
def remove_comment(self, topic_id, comment_id, reason='0', other=None):
"""
删除评论(自己发的话题所有的都可以删除,否则只能删自己发的)
:param topic_id: 话题ID
:param comment_id: 评论ID
:param reason: 原因 0/1/2 (内容不符/反动/其它)
:param other: 其它原因的具体(2)
:return: None
"""
params... | 删除评论(自己发的话题所有的都可以删除,否则只能删自己发的)
:param topic_id: 话题ID
:param comment_id: 评论ID
:param reason: 原因 0/1/2 (内容不符/反动/其它)
:param other: 其它原因的具体(2)
:return: None | entailment |
def list_user_comments(self, topic_id, user_alias=None):
"""
列出用户在话题下的所有回复
:param topic_id: 话题ID
:param user_alias: 用户ID,默认当前
:return: 纯列表
"""
user_alias = user_alias or self.api.user_alias
comment_start = 0
results = []
while comm... | 列出用户在话题下的所有回复
:param topic_id: 话题ID
:param user_alias: 用户ID,默认当前
:return: 纯列表 | entailment |
def remove_commented_topic(self, topic_id):
"""
删除回复的话题(删除所有自己发布的评论)
:param topic_id: 话题ID
:return: None
"""
return [self.remove_comment(topic_id, item['id']) for item in self.list_user_comments(topic_id)] | 删除回复的话题(删除所有自己发布的评论)
:param topic_id: 话题ID
:return: None | entailment |
def shell(name=None, **attrs):
"""Creates a new :class:`Shell` with a function as callback. This
works otherwise the same as :func:`command` just that the `cls`
parameter is set to :class:`Shell`.
"""
attrs.setdefault('cls', Shell)
return click.command(name, **attrs) | Creates a new :class:`Shell` with a function as callback. This
works otherwise the same as :func:`command` just that the `cls`
parameter is set to :class:`Shell`. | entailment |
def getLogger(name):
"""This is used by gcdt plugins to get a logger with the right level."""
logger = logging.getLogger(name)
# note: the level might be adjusted via '-v' option
logger.setLevel(logging_config['loggers']['gcdt']['level'])
return logger | This is used by gcdt plugins to get a logger with the right level. | entailment |
def _discover(self):
"""Discovers methods in the XML-RPC API and creates attributes for them
on this object. Enables stuff like "magento.cart.create(...)" to work
without having to define Python methods for each XML-RPC equivalent.
"""
self._resources = {}
resources = se... | Discovers methods in the XML-RPC API and creates attributes for them
on this object. Enables stuff like "magento.cart.create(...)" to work
without having to define Python methods for each XML-RPC equivalent. | entailment |
def keep_session_alive(self):
"""If the session expired, logs back in."""
try:
self.resources()
except xmlrpclib.Fault as fault:
if fault.faultCode == 5:
self.login()
else:
raise | If the session expired, logs back in. | entailment |
def help(self):
"""Prints discovered resources and their associated methods. Nice when
noodling in the terminal to wrap your head around Magento's insanity.
"""
print('Resources:')
print('')
for name in sorted(self._resources.keys()):
methods = sorted(self._r... | Prints discovered resources and their associated methods. Nice when
noodling in the terminal to wrap your head around Magento's insanity. | entailment |
def run(self):
"""Import the controller and run it.
This mimics the processing done by :func:`helper.start`
when a controller is run in the foreground. A new instance
of ``self.controller`` is created and run until a keyboard
interrupt occurs or the controller stops on its own ... | Import the controller and run it.
This mimics the processing done by :func:`helper.start`
when a controller is run in the foreground. A new instance
of ``self.controller`` is created and run until a keyboard
interrupt occurs or the controller stops on its own accord. | entailment |
def get_info(self):
"""
Scans the input path and automatically determines the optimal
piece size based on ~1500 pieces (up to MAX_PIECE_SIZE) along
with other basic info, including total size (in bytes), the
total number of files, piece size (in bytes), and resulting
numb... | Scans the input path and automatically determines the optimal
piece size based on ~1500 pieces (up to MAX_PIECE_SIZE) along
with other basic info, including total size (in bytes), the
total number of files, piece size (in bytes), and resulting
number of pieces. If ``piece_size`` has alre... | entailment |
def generate(self, callback=None):
"""
Computes and stores piece data. Returns ``True`` on success, ``False``
otherwise.
:param callback: progress/cancellation callable with method
signature ``(filename, pieces_completed, pieces_total)``.
Useful for reporting pro... | Computes and stores piece data. Returns ``True`` on success, ``False``
otherwise.
:param callback: progress/cancellation callable with method
signature ``(filename, pieces_completed, pieces_total)``.
Useful for reporting progress if dottorrent is used in a
GUI/thread... | entailment |
def info_hash_base32(self):
"""
Returns the base32 info hash of the torrent. Useful for generating
magnet links.
.. note:: ``generate()`` must be called first.
"""
if getattr(self, '_data', None):
return b32encode(sha1(bencode(self._data['info'])).digest())
... | Returns the base32 info hash of the torrent. Useful for generating
magnet links.
.. note:: ``generate()`` must be called first. | entailment |
def info_hash(self):
"""
:return: The SHA-1 info hash of the torrent. Useful for generating
magnet links.
.. note:: ``generate()`` must be called first.
"""
if getattr(self, '_data', None):
return sha1(bencode(self._data['info'])).hexdigest()
else... | :return: The SHA-1 info hash of the torrent. Useful for generating
magnet links.
.. note:: ``generate()`` must be called first. | entailment |
def req(self, url, method='get', params=None, data=None, auth=False):
"""
请求API
:type url: str
:param url: API
:type method: str
:param method: HTTP METHOD
:type params: dict
:param params: query
:type data: dict
... | 请求API
:type url: str
:param url: API
:type method: str
:param method: HTTP METHOD
:type params: dict
:param params: query
:type data: dict
:param data: body
:type auth: bool
:param auth: if True and sess... | entailment |
def json(self, url, method='get', params=None, data=None):
"""
请求并返回json
:type url: str
:param url: API
:type method: str
:param method: HTTP METHOD
:type params: dict
:param params: query
:type data: di... | 请求并返回json
:type url: str
:param url: API
:type method: str
:param method: HTTP METHOD
:type params: dict
:param params: query
:type data: dict
:param data: body
:rtype: dict
:return: | entailment |
def xml(self, url, method='get', params=None, data=None):
"""
请求并返回xml
:type url: str
:param url: API
:type method: str
:param method: HTTP METHOD
:type params: dict
:param params: query
:type data: dict
... | 请求并返回xml
:type url: str
:param url: API
:type method: str
:param method: HTTP METHOD
:type params: dict
:param params: query
:type data: dict
:param data: body
:rtype: html.HtmlElement
:return: | entailment |
def persist(self):
"""
持久化会话信息
"""
with open(self.persist_file, 'w+') as f:
json.dump({
'cookies': self.cookies,
'user_alias': self.user_alias,
}, f, indent=2)
self.logger.debug('persist session to <%s>' % self.persist_f... | 持久化会话信息 | entailment |
def load(self):
"""
加载会话信息
"""
if not os.path.isfile(self.persist_file):
return
with open(self.persist_file, 'r') as f:
cfg = json.load(f) or {}
self.cookies = cfg.get('cookies', {})
self.user_alias = cfg.get('user_alias') or None
... | 加载会话信息 | entailment |
def flush(self):
"""
更新会话信息,主要是ck, user_alias
"""
if 'dbcl2' not in self.cookies:
return
r = self.req(API_ACCOUNT_HOME)
if RE_SESSION_EXPIRE.search(r.url):
return self.expire()
self.cookies.update(dict(r.cookies))
self.user_alias = ... | 更新会话信息,主要是ck, user_alias | entailment |
def login(self, username, password):
"""
登录
:type username: str
:param username: 用户名(手机号或者邮箱)
:type password: str
:param password: 密码
"""
r0 = self.req(API_HOME)
time.sleep(1)
cookies = dict(r0.cookies)
data = {
... | 登录
:type username: str
:param username: 用户名(手机号或者邮箱)
:type password: str
:param password: 密码 | entailment |
def use(self, cookies):
"""
如果遭遇验证码,用这个接口
:type cookies: str|dict
:param cookies: cookie字符串或者字典
:return: self
"""
self.cookies = dict([item.split('=', 1) for item in re.split(r'; *', cookies)]) \
if isinstance(cookies, str) else cookies
... | 如果遭遇验证码,用这个接口
:type cookies: str|dict
:param cookies: cookie字符串或者字典
:return: self | entailment |
def logout(self):
"""
登出会话
:return: self
"""
self.req(API_ACCOUNT_LOGOUT % self.ck())
self.cookies = {}
self.user_alias = None
self.persist() | 登出会话
:return: self | entailment |
def deploy(awsclient, applicationName, deploymentGroupName,
deploymentConfigName, bucket, bundlefile):
"""Upload bundle and deploy to deployment group.
This includes the bundle-action.
:param applicationName:
:param deploymentGroupName:
:param deploymentConfigName:
:param bucket:
... | Upload bundle and deploy to deployment group.
This includes the bundle-action.
:param applicationName:
:param deploymentGroupName:
:param deploymentConfigName:
:param bucket:
:param bundlefile:
:return: deploymentId from create_deployment | entailment |
def output_deployment_status(awsclient, deployment_id, iterations=100):
"""Wait until an deployment is in an steady state and output information.
:param deployment_id:
:param iterations:
:return: exit_code
"""
counter = 0
steady_states = ['Succeeded', 'Failed', 'Stopped']
client_codedep... | Wait until an deployment is in an steady state and output information.
:param deployment_id:
:param iterations:
:return: exit_code | entailment |
def stop_deployment(awsclient, deployment_id):
"""stop tenkai deployment.
:param awsclient:
:param deployment_id:
"""
log.info('Deployment: %s - stopping active deployment.', deployment_id)
client_codedeploy = awsclient.get_client('codedeploy')
response = client_codedeploy.stop_deployment(... | stop tenkai deployment.
:param awsclient:
:param deployment_id: | entailment |
def _list_deployment_instances(awsclient, deployment_id):
"""list deployment instances.
:param awsclient:
:param deployment_id:
"""
client_codedeploy = awsclient.get_client('codedeploy')
instances = []
next_token = None
# TODO refactor generic exhaust_function from this
while True... | list deployment instances.
:param awsclient:
:param deployment_id: | entailment |
def _get_deployment_instance_summary(awsclient, deployment_id, instance_id):
"""instance summary.
:param awsclient:
:param deployment_id:
:param instance_id:
return: status, last_event
"""
client_codedeploy = awsclient.get_client('codedeploy')
request = {
'deploymentId': deploym... | instance summary.
:param awsclient:
:param deployment_id:
:param instance_id:
return: status, last_event | entailment |
def _get_deployment_instance_diagnostics(awsclient, deployment_id, instance_id):
"""Gets you the diagnostics details for the first 'Failed' event.
:param awsclient:
:param deployment_id:
:param instance_id:
return: None or (error_code, script_name, message, log_tail)
"""
client_codedeploy =... | Gets you the diagnostics details for the first 'Failed' event.
:param awsclient:
:param deployment_id:
:param instance_id:
return: None or (error_code, script_name, message, log_tail) | entailment |
def output_deployment_summary(awsclient, deployment_id):
"""summary
:param awsclient:
:param deployment_id:
"""
log.info('\ndeployment summary:')
log.info('%-22s %-12s %s', 'Instance ID', 'Status', 'Most recent event')
for instance_id in _list_deployment_instances(awsclient, deployment_id):... | summary
:param awsclient:
:param deployment_id: | entailment |
def output_deployment_diagnostics(awsclient, deployment_id, log_group, start_time=None):
"""diagnostics
:param awsclient:
:param deployment_id:
"""
headline = False
for instance_id in _list_deployment_instances(awsclient, deployment_id):
diagnostics = _get_deployment_instance_diagnostic... | diagnostics
:param awsclient:
:param deployment_id: | entailment |
def is_type(self):
"""
:return:
:rtype: bool
"""
if self.__is_type_result is not None:
return self.__is_type_result
self.__is_type_result = self.__is_type()
return self.__is_type_result | :return:
:rtype: bool | entailment |
def validate(self, error_message=None):
"""
:raises TypeError:
If the value is not matched the type that the class represented.
"""
if self.is_type():
return
if not error_message:
error_message = "invalid value type"
raise TypeError(... | :raises TypeError:
If the value is not matched the type that the class represented. | entailment |
def convert(self):
"""
:return: Converted value.
:raises typepy.TypeConversionError:
If the value cannot convert.
"""
if self.is_type():
return self.force_convert()
raise TypeConversionError(
"failed to convert from {} to {}".format(t... | :return: Converted value.
:raises typepy.TypeConversionError:
If the value cannot convert. | entailment |
def always_fails(
self,
work_dict):
"""always_fails
:param work_dict: dictionary for key/values
"""
label = "always_fails"
log.info(("task - {} - start "
"work_dict={}")
.format(label,
work_dict))
raise Exception(
wo... | always_fails
:param work_dict: dictionary for key/values | entailment |
def name_build(self, name, is_policy=False, prefix=True):
"""
Build name from prefix and name + type
:param name: Name of the role/policy
:param is_policy: True if policy should be added as suffix
:param prefix: True if prefix should be added
:return: Joined name
... | Build name from prefix and name + type
:param name: Name of the role/policy
:param is_policy: True if policy should be added as suffix
:param prefix: True if prefix should be added
:return: Joined name | entailment |
def name_strip(self, name, is_policy=False, prefix=True):
"""
Transforms name to AWS valid characters and adds prefix and type
:param name: Name of the role/policy
:param is_policy: True if policy should be added as suffix
:param prefix: True if prefix should be added
:re... | Transforms name to AWS valid characters and adds prefix and type
:param name: Name of the role/policy
:param is_policy: True if policy should be added as suffix
:param prefix: True if prefix should be added
:return: Transformed and joined name | entailment |
def build_policy(self, name, statements, roles, is_managed_policy=False):
"""
Generate policy for IAM cloudformation template
:param name: Name of the policy
:param statements: The "rules" the policy should have
:param roles: The roles associated with this policy
:param i... | Generate policy for IAM cloudformation template
:param name: Name of the policy
:param statements: The "rules" the policy should have
:param roles: The roles associated with this policy
:param is_managed_policy: True if managed policy
:return: Ref to new policy | entailment |
def build_policy_bucket(self, bucket, name, statements):
"""
Generate bucket policy for S3 bucket
:param bucket: The bucket to attach policy to
:param name: The name of the bucket (to generate policy name from it)
:param statements: The "rules" the policy should have
:ret... | Generate bucket policy for S3 bucket
:param bucket: The bucket to attach policy to
:param name: The name of the bucket (to generate policy name from it)
:param statements: The "rules" the policy should have
:return: Ref to new policy | entailment |
def build_role(self, name, policies=False):
"""
Generate role for IAM cloudformation template
:param name: Name of role
:param policies: List of policies to attach to this role (False = none)
:return: Ref to new role
"""
# Build role template
if policies:
... | Generate role for IAM cloudformation template
:param name: Name of role
:param policies: List of policies to attach to this role (False = none)
:return: Ref to new role | entailment |
def build_bucket(self, name, lifecycle_configuration=False,
use_plain_name=False):
"""
Generate S3 bucket statement
:param name: Name of the bucket
:param lifecycle_configuration: Additional lifecycle configuration (default=False)
:param use_plain_name: Just ... | Generate S3 bucket statement
:param name: Name of the bucket
:param lifecycle_configuration: Additional lifecycle configuration (default=False)
:param use_plain_name: Just use the given name and do not add prefix
:return: Ref to new bucket | entailment |
def directive_SPACE(self, label, params):
"""
label SPACE num
Allocate space on the stack. `num` is the number of bytes to allocate
"""
# TODO allow equations
params = params.strip()
try:
self.convert_to_integer(params)
except ValueError:
... | label SPACE num
Allocate space on the stack. `num` is the number of bytes to allocate | entailment |
def directive_DCD(self, label, params):
"""
label DCD value[, value ...]
Allocate a word space in read only memory for the value or list of values
"""
# TODO make this read only
# TODO check for param size
# TODO can take any length comma separated values (VAL ... | label DCD value[, value ...]
Allocate a word space in read only memory for the value or list of values | entailment |
def directive_DCH(self, label, params):
"""
label DCH value[, value ...]
Allocate a half word space in read only memory for the value or list of values
"""
# TODO make this read only
# TODO check for word size
# Align address
if self.space_pointer % 2 ... | label DCH value[, value ...]
Allocate a half word space in read only memory for the value or list of values | entailment |
def directive_DCB(self, label, params):
"""
label DCB value[, value ...]
Allocate a byte space in read only memory for the value or list of values
"""
# TODO make this read only
# TODO check for byte size
self.labels[label] = self.space_pointer
if param... | label DCB value[, value ...]
Allocate a byte space in read only memory for the value or list of values | entailment |
def get_celery_app(
name=os.getenv(
"CELERY_NAME",
"worker"),
auth_url=os.getenv(
"BROKER_URL",
"redis://localhost:6379/9"),
backend_url=os.getenv(
"BACKEND_URL",
"redis://localhost:6379/10"),
include_tasks=[],
... | get_celery_app
:param name: name for this app
:param auth_url: celery broker
:param backend_url: celery backend
:param include_tasks: list of modules containing tasks to add
:param ssl_options: security options dictionary
:param trasport_options: transport options dictionary
:param path_to_... | entailment |
def check_arguments(self, **kwargs):
"""
Determine if the parameters meet the specifications
kwargs contains lists grouped by their parameter
rules are defined by methods starting with 'rule_'
:param kwargs:
:return:
"""
for key in kwargs:
if k... | Determine if the parameters meet the specifications
kwargs contains lists grouped by their parameter
rules are defined by methods starting with 'rule_'
:param kwargs:
:return: | entailment |
def link(self, key1, key2):
"""
Make these two keys have the same value
:param key1:
:param key2:
:return:
"""
# TODO make this have more than one key linked
# TODO Maybe make the value a set?
self._linked_keys[key1] = key2
self._linked_key... | Make these two keys have the same value
:param key1:
:param key2:
:return: | entailment |
def instance_ik_model_receiver(fn):
"""
A method decorator that filters out sign_original_specals coming from models that don't
have fields that function as ImageFieldSourceGroup sources.
"""
@wraps(fn)
def receiver(self, sender, **kwargs):
# print 'inspect.isclass(sender? %s'%(inspect.... | A method decorator that filters out sign_original_specals coming from models that don't
have fields that function as ImageFieldSourceGroup sources. | entailment |
def source_group_receiver(self, sender, source, signal, **kwargs):
"""
Relay source group signals to the appropriate spec strategy.
"""
from imagekit.cachefiles import ImageCacheFile
source_group = sender
instance = kwargs['instance']
# Ignore signals from unre... | Relay source group signals to the appropriate spec strategy. | entailment |
def update_source_hashes(self, instance):
"""
Stores hashes of the source image files so that they can be compared
later to see whether the source image has changed (and therefore whether
the spec file needs to be regenerated).
"""
self.init_instance(instance)
in... | Stores hashes of the source image files so that they can be compared
later to see whether the source image has changed (and therefore whether
the spec file needs to be regenerated). | entailment |
def get_source_fields(self, instance):
"""
Returns a list of the source fields for the given instance.
"""
return set(src.image_field
for src in self._source_groups
if isinstance(instance, src.model_class)) | Returns a list of the source fields for the given instance. | entailment |
def on_success(self, retval, task_id, args, kwargs):
"""on_success
http://docs.celeryproject.org/en/latest/reference/celery.app.task.html
:param retval: return value
:param task_id: celery task id
:param args: arguments passed into task
:param kwargs: keyword arguments ... | on_success
http://docs.celeryproject.org/en/latest/reference/celery.app.task.html
:param retval: return value
:param task_id: celery task id
:param args: arguments passed into task
:param kwargs: keyword arguments passed into task | entailment |
def on_failure(self, exc, task_id, args, kwargs, einfo):
"""on_failure
http://docs.celeryproject.org/en/latest/userguide/tasks.html#task-inheritance
:param exc: exception
:param task_id: task id
:param args: arguments passed into task
:param kwargs: keyword arguments pa... | on_failure
http://docs.celeryproject.org/en/latest/userguide/tasks.html#task-inheritance
:param exc: exception
:param task_id: task id
:param args: arguments passed into task
:param kwargs: keyword arguments passed into task
:param einfo: exception info | entailment |
def check_hook_mechanism_is_intact(module):
"""Check if the hook configuration is absent or has both register AND deregister.
:param module:
:return: True if valid plugin / module.
"""
result = True
if check_register_present(module):
result = not result
if check_deregister_present(m... | Check if the hook configuration is absent or has both register AND deregister.
:param module:
:return: True if valid plugin / module. | entailment |
def cfn_viz(template, parameters={}, outputs={}, out=sys.stdout):
"""Render dot output for cloudformation.template in json format.
"""
known_sg, open_sg = _analyze_sg(template['Resources'])
(graph, edges) = _extract_graph(template.get('Description', ''),
template['Res... | Render dot output for cloudformation.template in json format. | entailment |
def _get_fillcolor(resource_type, properties, known_sg=[], open_sg=[]):
"""Determine fillcolor for resources (public ones in this case)
"""
fillcolor = None
# check security groups
if 'SecurityGroups' in properties:
# check for external security groups
for sg in properties['SecurityG... | Determine fillcolor for resources (public ones in this case) | entailment |
def svg_output(dotfile, outfile='cloudformation.svg'):
"""Render template into svg file using the dot command (must be installed).
:param dotfile: path to the dotfile
:param outfile: filename for the output file
:return:
"""
try:
cmd = ['dot', '-Tsvg', '-o' + outfile, dotfile]
s... | Render template into svg file using the dot command (must be installed).
:param dotfile: path to the dotfile
:param outfile: filename for the output file
:return: | entailment |
def start(controller_class):
"""Start the Helper controller either in the foreground or as a daemon
process.
:param controller_class: The controller class handle to create and run
:type controller_class: callable
"""
args = parser.parse()
obj = controller_class(args, platform.operating_sys... | Start the Helper controller either in the foreground or as a daemon
process.
:param controller_class: The controller class handle to create and run
:type controller_class: callable | entailment |
def run(self, steps=float('inf')):
"""
Run to the current end of the program or a number of steps
:return:
"""
while len(self.program) > (self.register['PC'] - 1):
steps -= 1
if steps < 0:
break
self.program[self.register['PC'] ... | Run to the current end of the program or a number of steps
:return: | entailment |
def _validate_type(self, name, obj, *args):
"""
Helper function that checks the input object type against each in a list of classes. This function
also allows the input value to be equal to None.
:param name: Name of the object.
:param obj: Object to check the type of.
:... | Helper function that checks the input object type against each in a list of classes. This function
also allows the input value to be equal to None.
:param name: Name of the object.
:param obj: Object to check the type of.
:param args: List of classes.
:raises TypeError: if the i... | entailment |
def _validate_list_type(self, name, obj, *args):
"""
Helper function that checks the input object type against each in a list of classes, or if the input object
is a list, each value that it contains against that list.
:param name: Name of the object.
:param obj: Object to check... | Helper function that checks the input object type against each in a list of classes, or if the input object
is a list, each value that it contains against that list.
:param name: Name of the object.
:param obj: Object to check the type of.
:param args: List of classes.
:raises T... | entailment |
def _validate_nested_list_type(self, name, obj, nested_level, *args):
"""
Helper function that checks the input object as a list then recursively until nested_level is 1.
:param name: Name of the object.
:param obj: Object to check the type of.
:param nested_level: Integer with ... | Helper function that checks the input object as a list then recursively until nested_level is 1.
:param name: Name of the object.
:param obj: Object to check the type of.
:param nested_level: Integer with the current nested level.
:param args: List of classes.
:raises TypeError:... | entailment |
def B(self, params):
"""
B label
Unconditional branch to the address at label
"""
label = self.get_one_parameter(self.ONE_PARAMETER, params)
self.check_arguments(label_exists=(label,))
# TODO check if label is within +- 2 KB
# B label
def B_func... | B label
Unconditional branch to the address at label | entailment |
def BL(self, params):
"""
BL label
Branch to the label, storing the next instruction in the Link Register
"""
label = self.get_one_parameter(self.ONE_PARAMETER, params)
self.check_arguments(label_exists=(label,))
# TODO check if label is within +- 16 MB
... | BL label
Branch to the label, storing the next instruction in the Link Register | entailment |
def BLX(self, params):
"""
BLX Rj
Branch to the address in Rj, storing the next instruction in the Link Register
"""
Rj = self.get_one_parameter(self.ONE_PARAMETER, params)
self.check_arguments(LR_or_general_purpose_registers=(Rj,))
def BLX_func():
... | BLX Rj
Branch to the address in Rj, storing the next instruction in the Link Register | entailment |
def BX(self, params):
"""
BX Rj
Jump to the address in the Link Register
"""
Rj = self.get_one_parameter(self.ONE_PARAMETER, params)
self.check_arguments(LR_or_general_purpose_registers=(Rj,))
def BX_func():
self.register['PC'] = self.register[Rj]
... | BX Rj
Jump to the address in the Link Register | entailment |
def get_version(version):
"""
Returns a PEP 440-compliant version number from VERSION.
Created by modifying django.utils.version.get_version
"""
# Now build the two parts of the version number:
# major = X.Y[.Z]
# sub = .devN - for development releases
# | {a|b|rc}N - for alpha, be... | Returns a PEP 440-compliant version number from VERSION.
Created by modifying django.utils.version.get_version | entailment |
def get_git_changeset():
"""Returns a numeric identifier of the latest git changeset.
The result is the UTC timestamp of the changeset in YYYYMMDDHHMMSS format.
This value isn't guaranteed to be unique, but collisions are very unlikely,
so it's sufficient for generating the development version numbers.... | Returns a numeric identifier of the latest git changeset.
The result is the UTC timestamp of the changeset in YYYYMMDDHHMMSS format.
This value isn't guaranteed to be unique, but collisions are very unlikely,
so it's sufficient for generating the development version numbers. | entailment |
def load_cloudformation_template(path=None):
"""Load cloudformation template from path.
:param path: Absolute or relative path of cloudformation template. Defaults to cwd.
:return: module, success
"""
if not path:
path = os.path.abspath('cloudformation.py')
else:
path = os.path.... | Load cloudformation template from path.
:param path: Absolute or relative path of cloudformation template. Defaults to cwd.
:return: module, success | entailment |
def get_parameter_diff(awsclient, config):
"""get differences between local config and currently active config
"""
client_cf = awsclient.get_client('cloudformation')
try:
stack_name = config['stack']['StackName']
if stack_name:
response = client_cf.describe_stacks(StackName=s... | get differences between local config and currently active config | entailment |
def call_pre_hook(awsclient, cloudformation):
"""Invoke the pre_hook BEFORE the config is read.
:param awsclient:
:param cloudformation:
"""
# TODO: this is deprecated!! move this to glomex_config_reader
# no config available
if not hasattr(cloudformation, 'pre_hook'):
# hook is not... | Invoke the pre_hook BEFORE the config is read.
:param awsclient:
:param cloudformation: | entailment |
def deploy_stack(awsclient, context, conf, cloudformation, override_stack_policy=False):
"""Deploy the stack to AWS cloud. Does either create or update the stack.
:param conf:
:param override_stack_policy:
:return: exit_code
"""
stack_name = _get_stack_name(conf)
parameters = _generate_para... | Deploy the stack to AWS cloud. Does either create or update the stack.
:param conf:
:param override_stack_policy:
:return: exit_code | entailment |
def delete_stack(awsclient, conf, feedback=True):
"""Delete the stack from AWS cloud.
:param awsclient:
:param conf:
:param feedback: print out stack events (defaults to True)
"""
client_cf = awsclient.get_client('cloudformation')
stack_name = _get_stack_name(conf)
last_event = _get_sta... | Delete the stack from AWS cloud.
:param awsclient:
:param conf:
:param feedback: print out stack events (defaults to True) | entailment |
def list_stacks(awsclient):
"""Print out the list of stacks deployed at AWS cloud.
:param awsclient:
:return:
"""
client_cf = awsclient.get_client('cloudformation')
response = client_cf.list_stacks(
StackStatusFilter=[
'CREATE_IN_PROGRESS', 'CREATE_COMPLETE', 'ROLLBACK_IN_PR... | Print out the list of stacks deployed at AWS cloud.
:param awsclient:
:return: | entailment |
def describe_change_set(awsclient, change_set_name, stack_name):
"""Print out the change_set to console.
This needs to run create_change_set first.
:param awsclient:
:param change_set_name:
:param stack_name:
"""
client = awsclient.get_client('cloudformation')
status = None
while s... | Print out the change_set to console.
This needs to run create_change_set first.
:param awsclient:
:param change_set_name:
:param stack_name: | entailment |
def delete_change_set(awsclient, change_set_name, stack_name):
"""Delete specified change set. Currently we only use this during
automated regression testing. But we have plans so lets locate this
functionality here
:param awsclient:
:param change_set_name:
:param stack_name:
"""
client... | Delete specified change set. Currently we only use this during
automated regression testing. But we have plans so lets locate this
functionality here
:param awsclient:
:param change_set_name:
:param stack_name: | entailment |
def write_template_to_file(conf, template_body):
"""Writes the template to disk
"""
template_file_name = _get_stack_name(conf) + '-generated-cf-template.json'
with open(template_file_name, 'w') as opened_file:
opened_file.write(template_body)
print('wrote cf-template for %s to disk: %s' % (
... | Writes the template to disk | entailment |
def generate_template(context, config, cloudformation):
"""call cloudformation to generate the template (json format).
:param context:
:param config:
:param cloudformation:
:return:
"""
spec = inspect.getargspec(cloudformation.generate_template)[0]
if len(spec) == 0:
return clou... | call cloudformation to generate the template (json format).
:param context:
:param config:
:param cloudformation:
:return: | entailment |
def info(awsclient, config, format=None):
"""
collect info and output to console
:param awsclient:
:param config:
:param json: True / False to use json format as output
:return:
"""
if format is None:
format = 'tabular'
stack_name = _get_stack_name(config)
client_cfn = a... | collect info and output to console
:param awsclient:
:param config:
:param json: True / False to use json format as output
:return: | entailment |
def BCC(self, params):
"""
BCC label
Branch to the instruction at label if the C flag is not set
"""
label = self.get_one_parameter(self.ONE_PARAMETER, params)
self.check_arguments(label_exists=(label,))
# BCC label
def BCC_func():
if not se... | BCC label
Branch to the instruction at label if the C flag is not set | entailment |
def BCS(self, params):
"""
BCS label
Branch to the instruction at label if the C flag is set
"""
label = self.get_one_parameter(self.ONE_PARAMETER, params)
self.check_arguments(label_exists=(label,))
# BCS label
def BCS_func():
if self.is_C_... | BCS label
Branch to the instruction at label if the C flag is set | entailment |
def BEQ(self, params):
"""
BEQ label
Branch to the instruction at label if the Z flag is set
"""
label = self.get_one_parameter(self.ONE_PARAMETER, params)
self.check_arguments(label_exists=(label,))
# BEQ label
def BEQ_func():
if self.is_Z_... | BEQ label
Branch to the instruction at label if the Z flag is set | entailment |
def BGE(self, params):
"""
BGE label
Branch to the instruction at label if the N flag is the same as the V flag
"""
label = self.get_one_parameter(self.ONE_PARAMETER, params)
self.check_arguments(label_exists=(label,))
# BGE label
def BGE_func():
... | BGE label
Branch to the instruction at label if the N flag is the same as the V flag | entailment |
def BGT(self, params):
"""
BGT label
Branch to the instruction at label if the N flag is the same as the V flag and the Z flag is not set
"""
label = self.get_one_parameter(self.ONE_PARAMETER, params)
self.check_arguments(label_exists=(label,))
# BGT label
... | BGT label
Branch to the instruction at label if the N flag is the same as the V flag and the Z flag is not set | entailment |
def BHI(self, params):
"""
BHI label
Branch to the instruction at label if the C flag is set and the Z flag is not set
"""
label = self.get_one_parameter(self.ONE_PARAMETER, params)
self.check_arguments(label_exists=(label,))
# BHI label
def BHI_func():... | BHI label
Branch to the instruction at label if the C flag is set and the Z flag is not set | entailment |
def BHS(self, params):
"""
BHS label
Branch to the instruction at label if the C flag is set
"""
label = self.get_one_parameter(self.ONE_PARAMETER, params)
self.check_arguments(label_exists=(label,))
# BHS label
def BHS_func():
if self.is_C_... | BHS label
Branch to the instruction at label if the C flag is set | entailment |
def BLE(self, params):
"""
BLE label
Branch to the instruction at label if the Z flag is set or if the N flag is not the same as the V flag
"""
label = self.get_one_parameter(self.ONE_PARAMETER, params)
self.check_arguments(label_exists=(label,))
# BLE label
... | BLE label
Branch to the instruction at label if the Z flag is set or if the N flag is not the same as the V flag | entailment |
def BLO(self, params):
"""
BLO label
Branch to the instruction at label if the C flag is not set
"""
label = self.get_one_parameter(self.ONE_PARAMETER, params)
self.check_arguments(label_exists=(label,))
# BLO label
def BLO_func():
if not se... | BLO label
Branch to the instruction at label if the C flag is not set | entailment |
def BLS(self, params):
"""
BLS label
Branch to the instruction at label if the C flag is not set or the Z flag is set
"""
label = self.get_one_parameter(self.ONE_PARAMETER, params)
self.check_arguments(label_exists=(label,))
# BLS label
def BLS_func():
... | BLS label
Branch to the instruction at label if the C flag is not set or the Z flag is set | entailment |
def BLT(self, params):
"""
BLT label
Branch to the instruction at label if the N flag is not the same as the V flag
"""
label = self.get_one_parameter(self.ONE_PARAMETER, params)
self.check_arguments(label_exists=(label,))
# BLT label
def BLT_func():
... | BLT label
Branch to the instruction at label if the N flag is not the same as the V flag | entailment |
def BMI(self, params):
"""
BMI label
Branch to the instruction at label if the N flag is set
"""
label = self.get_one_parameter(self.ONE_PARAMETER, params)
self.check_arguments(label_exists=(label,))
# BMI label
def BMI_func():
if self.is_N_... | BMI label
Branch to the instruction at label if the N flag is set | entailment |
def BNE(self, params):
"""
BNE label
Branch to the instruction at label if the Z flag is not set
"""
label = self.get_one_parameter(self.ONE_PARAMETER, params)
self.check_arguments(label_exists=(label,))
# BNE label
def BNE_func():
if not se... | BNE label
Branch to the instruction at label if the Z flag is not set | entailment |
def BPL(self, params):
"""
BPL label
Branch to the instruction at label if the N flag is set
"""
label = self.get_one_parameter(self.ONE_PARAMETER, params)
self.check_arguments(label_exists=(label,))
# BPL label
def BPL_func():
if not self.i... | BPL label
Branch to the instruction at label if the N flag is set | entailment |
def BVC(self, params):
"""
BVC label
Branch to the instruction at label if the V flag is not set
"""
label = self.get_one_parameter(self.ONE_PARAMETER, params)
self.check_arguments(label_exists=(label,))
# BVC label
def BVC_func():
if not se... | BVC label
Branch to the instruction at label if the V flag is not set | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.